鱼C论坛

 找回密码
 立即注册
查看: 2094|回复: 1

有关于requests_html的爬虫问题

[复制链接]
发表于 2020-5-10 10:13:02 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
在学习爬虫的时候,我碰到一段代码。输出的结果我看不懂,不知道要如何才能提取信息。请教各位,感谢!
  1. from requests_html import HTMLSession
  2. session = HTMLSession()

  3. links = ['http://stock.finance.sina.com.cn/usstock/quotes/aapl.html', \
  4.          'http://stock.finance.sina.com.cn/usstock/quotes/bidu.html', \
  5.          'http://stock.finance.sina.com.cn/usstock/quotes/msft.html']

  6. for link in links:
  7.     r = session.get(link)
  8.     r.html.render()
  9.     price = r.html.find('#hqPrice', first=True)
  10.     print(price)
复制代码


输出的结果如下:
  1. <Element 'div' class=('hq_now', 'up') id='hqPrice' style='color: silver;'>
  2. <Element 'div' class=('hq_now', 'up') id='hqPrice' style=''>
  3. <Element 'div' class=('hq_now', 'up') id='hqPrice' style=''>
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-5-10 10:27:46 | 显示全部楼层
返回的应该是是一个Element对象,Element
应该有一些方法可以提取数据,你百度搜搜。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-30 04:53

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表