python实现凤凰新闻监控
来源:互联网 发布:pushkit python 编辑:程序博客网 时间:2024/05/17 16:11
由于任务需求,要关注凤凰新闻网相关报道,要做到出现相关报道报警来通知我,时间紧凑,本人水平也有限,写的比较简单,请见谅。如有人实现过类似功能,也请多多指教。下面直接贴代码了。
#_*_ coding:utf-8 _*_from bs4 import BeautifulSoupimport urllibimport codecsimport timeimport osdef setstr(st): instr = st.split(); outstr='' for it in instr: outstr=outstr+it+' ' return outstrdef findstr(ite): if (ite.find(u'关键字1')!=-1) or (ite.find(u'关键字2')!=-1) or (ite.find(u'关键字3')!=-1): f = codecs.open('sys.txt','a+','utf-8') txt = f.read() if txt.find(ite)==-1: f.write(ite) f.write('\r\n') f.close() return 1 else: f.close() return 0 else: return 0def fun(url): soup = BeautifulSoup(urllib.urlopen(url).read()) s0 = soup.find_all('div',{'class':'newsList'}) s1=BeautifulSoup(s0[0].prettify()) s2= s1.find_all('li') for item in s2: sss=item.get_text().lstrip().rstrip().replace('\n','') str1=setstr(sss) if findstr(str1): os.system("start wmplayer.exe C:\\sound.mp3") print str1if __name__=="__main__": url = 'http://news.ifeng.com/listpage/11502/0/1/rtlist.shtml' while(1): fun(url) time.sleep(60)
0 0
- python实现凤凰新闻监控
- iPhone网易新闻和凤凰新闻客户端
- Python 实现腾讯新闻抓取
- Python 实现腾讯新闻抓取
- 凤凰
- win 8 store app 凤凰新闻阅读器 隐私声明
- Android练手小项目---仿凤凰新闻app
- Python:通过摄像头实现的监控功能
- Python:通过摄像头实现的监控功能
- Python实现对电脑的全程监控
- 树莓派+python opencv实现远程监控
- Python实现Windows监控agent(上)
- Python实现Windows监控agent(下)
- Python实现对Tomcat的监控
- 树莓派+python opencv实现远程监控
- Python实现对电脑的全程监控
- Postgresql 使用 Pl/python实现邮件监控
- Python实现京东价格监控
- 错误代码: 1248 Every derived table must have its own alias
- nyoj题目238:小明的调查统计
- 监听屏幕点亮和关闭状态
- 4.19
- Simulate Common Stochastic Process
- python实现凤凰新闻监控
- java学习之类与继承
- Python发送邮件
- 使用Camera进行拍照 & 后台静默拍照的思路
- sizeof和strlen的区别
- c++模板
- matlab 写txt 保存日志
- 4.20
- 交换一个整数的相邻奇数位与偶数位(即第0位与第1位交换,第2位与第3位交换...)