本文实例讲述了Python抓取百度查询结果的方法。分享给大家供大家参考。具体实现方法如下:
#win python 2.7.ximport re,sys,urllib,codecsxh = urllib.urlopen("http://pile(r'<[^>]+>',re.I)f = codecs.open("xiaohei.txt", "w", "utf-8")for i in rc.finditer(xh): ss = i.group(0) s1 = rcr.sub('',ss) print (s1) f.write(s1)f.close()希望本文所述对大家的Python程序设计有所帮助。