随笔分类 -  Python

Python采集网页数据保存到excel
摘要:urllib读取网页,然后用Py-excel写excel。import urllibfrom xlwt import Workbookimport datetimedef FetchData(): book = Workbook(encoding='gbk') #如果采集数据有中文,需要添加这个 sheet1 = book.add_sheet('Sheet 2') #表格缓存 i = 0 theday = datetime.date(2009,12,31) while i < 100: #这边的场景就是采集100个网页,每个网址都包含日期 ... 阅读全文

posted @ 2013-05-05 17:35 seaven 阅读(8486) 评论(0) 推荐(0)

使用Python抓取网页图片[转载]
摘要:ImgDownloaderimport win32com.client,time,win32inet,win32file,osclass ImgDownloader: def __init__(self,url,dir): self.__dir=dir self.__ie=win32com.client.Dispatch('InternetExplorer.Application') self.__ie.Navigate(url) self.__wait__() def __wait__(self): while... 阅读全文

posted @ 2013-05-03 09:14 seaven 阅读(528) 评论(0) 推荐(0)

导航