반응형 전체 글463 [파이썬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. [디시인사이드] 김소혜 게시판 크롤링 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": print("%s : %s" % (s.get.. 2017. 1. 6. 이전 1 ··· 111 112 113 114 115 116 다음 반응형