본문 바로가기
  • Let's go grab a data
Data/Python

Web Scraper 기본

by pub-lican-ai 2018. 5. 18.
반응형


[필요 모듈]

requests

BeuatifulSoup4  - HTML를 파싱하기 좋게 파이썬 객체로 리턴

lxml  - 파싱가능한 HTML으로 변경


[요청하기]

import requests

res = requests.get('http://book.naver.com')

res.text

'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\r\n<html lang="ko">\r\n<head>.......



[proxy 있는 경우]

from requests.auth import HTTPProxyAuth


proxyDict = {

    'http' : '70.10.15.10:8080',

    'https' : '70.10.15.10:8080'

}

res = requests.get('http://book.naver.com', proxies=proxyDict)


작성중

반응형

'Data > Python' 카테고리의 다른 글

Scrapy 크롤러 기본  (0) 2018.12.06
윈도우에서 웹 크롤링 Windows Web Crawling 환경설정  (0) 2018.12.03
Python IDE 개발환경, pip proxy ssl 문제해결  (0) 2018.05.10
자료형 - List  (0) 2018.02.13
날짜 다루기  (0) 2018.02.07