python3|python3 BeautifulSoup爬去股票信息
【python3|python3 BeautifulSoup爬去股票信息】爬网页信息用到了BeautifulSoup这个,通过这个库能很好的解析网页信息,可以从标签 css等方式取信息 .
import requests
from bs4 import BeautifulSoupheaders = {'user-agent':'Mozilla/5.0 (Windows NT 6.1;
WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'}
reponse = requests.get('http://quote.stockstar.com/stock/gem.shtml')
reponse.encoding = 'GBK'
soup = BeautifulSoup(reponse.text,'lxml')
trs = soup.select('tbody.tbody_right')[0].select('tr')
for i in trs:
print(i.text)
print('*'*50)
datalist = soup.find_all(id='datalist')
for a in datalist[0].select('tr'):
print(a.text)
文章图片
BaiduShurufa_2019-1-20_22-16-4.png
推荐阅读
- Python3|Python3 MySQL 数据库连接
- win10环境|win10环境 python3.6安装pycrypto-2.6.1的问题
- 分布式|《Python3网络爬虫开发实战(第二版)》内容介绍
- python3|python3 模块 包
- Python3.x(Socket网络编程)
- 树莓派|树莓派 | 04 安装基于python3.5的tensorflow,解决python版本不匹配问题
- ubuntu下安装python3.6及以上版本出现pip3报错等问题
- python实现gui编程_怎样用Python3实现GUI编程()
- Python3.7操作MySQL8.0.15数据库
- pip|pip install pycryptodome python3 AES