데이터 Crawling 시에 python 코드 샘플
# # import modules # import MySQLdb import urllib import re # #URL # MAIN_URL = "http://www.test.com" # #TMPL # TMPL = "" # # CLASS crawler # class Crawler(object): def __init__(self): self.db = MySQLdb.connect(host="",user="",passwd="",db="") self.cur = self.db.cursor() def __del__(self): self.db.close() def run(self): html = urllib.urlopen(MAIN_URL) page = html.read() match = re.compile(TMPL , re.DOTALL) match_list = match.findall(page) if __name__ == "__main__": crawler = Crawler() crawler.run()
'Python' 카테고리의 다른 글
[python] 직접 만든 module import 시 import 한 클래스에 파일을 로드할 시 주의! (0) | 2014.10.20 |
---|---|
[Python] PyQt 튜토리얼 (0) | 2014.10.08 |
[python]python file download (0) | 2014.09.25 |
List 필터링(Filtering) (0) | 2014.09.24 |
map function (0) | 2014.09.24 |