1 #baidu_hotword.py
 2 #get baidu hotword in news.baidu.com
 3 import urllib2
 4 import os
 5 import re
 6 
 7 def getHtml(url):
 8     page = urllib2.urlopen(url)
 9     html = page.read()
10     page.close()
11     return html
12 
13 def getHotWord(html):
14     reg = '<li.*?hotwords_li_a.*?title="(.*?)".*?</li>'
15     hotwords = re.compile(reg).findall(html)
16     return hotwords
17 
18 if __name__ == '__main__':
19     html = getHtml('http://news.baidu.com/')
20     #print(html)
21     hotwds = getHotWord(html)
22     for i in hotwds:
23         print unicode(i, "gb2312")
View Code

相关文章:

  • 2021-05-10
  • 2021-08-07
  • 2021-12-21
  • 2021-09-29
  • 2022-01-06
  • 2021-11-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
  • 2021-08-10
  • 2021-07-24
相关资源
相似解决方案