|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
在学习爬虫的时候,我碰到一段代码。输出的结果我看不懂,不知道要如何才能提取信息。请教各位,感谢!
- from requests_html import HTMLSession
- session = HTMLSession()
- links = ['http://stock.finance.sina.com.cn/usstock/quotes/aapl.html', \
- 'http://stock.finance.sina.com.cn/usstock/quotes/bidu.html', \
- 'http://stock.finance.sina.com.cn/usstock/quotes/msft.html']
- for link in links:
- r = session.get(link)
- r.html.render()
- price = r.html.find('#hqPrice', first=True)
- print(price)
复制代码
输出的结果如下:
- <Element 'div' class=('hq_now', 'up') id='hqPrice' style='color: silver;'>
- <Element 'div' class=('hq_now', 'up') id='hqPrice' style=''>
- <Element 'div' class=('hq_now', 'up') id='hqPrice' style=''>
复制代码 |
|