Python获取中国证券报最新资讯

 1 # -*- coding: utf-8 -*-
 2 import urllib
 3 from bs4 import BeautifulSoup
 4 from time import time
 5 from time import ctime
 6 def get_last_info():
 7 url='http://ggjd.cnstock.com/gglist/search/ggkx/0'
 8 
 9 html=urllib.urlopen(url)
10 
11 bsobj2=BeautifulSoup(html,"lxml")
12 
13 alltext=bsobj2.body.findAll("ul",class_="new-list")
14 #print alltext[1].get_text()#ok,需要的信息在第二个new-list
15 l_2=len(alltext)
16 
17 file_open=open(r'C:\Users\Administrator\Desktop\securities\securities_info1.txt','w')
18 
19 t1= alltext[1].get_text()
20 
21 t1=t1.encode("utf-8")
22 t1="<获取信息时间>:%s\n"%ctime()+url+'\n'+"中国证券网->上市公司专区->信息披露与公告解读->公告快讯:"+t1
23 
24 print t1
25 file_open.write(t1)
26 file_open.close()
27 if __name__=="__main__":
28 get_last_info()

 

转载于:https://www.cnblogs.com/willowj/p/6246491.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值