반응형 Python193 [네이버]뉴스 크롤링 import urllib.requestimport urllib.parse from bs4 import BeautifulSoup defaultURL = 'https://openapi.naver.com/v1/search/news.xml?'sort = '&sort=sim'start = '&start=1'display = '&display=100'query = '&query='+urllib.parse.quote_plus(str(input("검색어: "))) fullURL = defaultURL + sort + start + display + query print(fullURL) file = open("C:\\Python34\\naver_news.txt","w",encoding='utf-8') headers = .. 2017. 1. 8. [파이썬3] beautiful soup 예제 #모든 웹사이트 긁어오기 import urllib.request from bs4 import BeautifulSoup req = urllib.request.Request("http://news.naver.com");data = urllib.request.urlopen(req).read()bs = BeautifulSoup(data, 'html.parser')print(bs) 2017. 1. 6. [파이썬3] lxml 설치하기 Beautiful Soup 파싱도구를 더 잘 활용하기 위한 lxml 설치하기 1. (cmd)탐색기에서 C:\파이썬 설치폴더\Scripts의 디렉토리로 이동 2. 명령어 pip install lxml 입력 2017. 1. 6. [디시인사이드] 김소혜 게시판 댓글 웹 크롤링 from bs4 import BeautifulSoupimport urllib.request if __name__ == "__main__": req = urllib.request.Request("http://gall.dcinside.com/board/lists/?id=kimsohye");data = urllib.request.urlopen(req).read()bs = BeautifulSoup(data, 'html.parser')l = bs.find_all('a')idx = 0 for s in l : try : prop = s.get('class')# get class propertyif prop != None and prop[0] == "icon_pic_n": a = "%s : %s" % (s.get('h.. 2017. 1. 6. 이전 1 ··· 44 45 46 47 48 49 다음 반응형