通过urllib2抓取HTML网页,然后过滤出包含特定字符的行,并写入Excel文件:
# -*- coding: utf-8 -*-import sys#import urllibimport urllib2from xlwt import Workbookdef getdata(keywords, line): date = '' if keywords in line: # 本行包含keywords start = line.find('>',) end = line.find('
输出结果: