路透社的网络报废库存数据
我是一个编程初学者,并试图从路透社提取关键的度量数据(例如beta)。但是,它总是像空白一样回来。
我的代码是这样的:
from bs4 import BeautifulSoup as bs
import requests
import re
url = 'https://www.reuters.com/markets/companies/TSLA.OQ/key-metrics/price-and-volume'
page = requests.get(url)
bs1 = bs(page.text, 'html.parser')
beta=bs1.find_all('th', class_ ='text__text__1FZLe text__dark-grey__3Ml43 text__regular__2N1Xr text__body__yKS5U body__base__22dCE body__body__VgU9Q',text=re.compile('Beta'))
print(beta)
我知道这是不正确的,但我无法弄清楚该怎么办。请帮忙。最终,我想从路透社提取股票的Beta信息。感谢您的帮助!!!
I am a programming beginner and trying to extract key metric data (e.g. Beta) for a stock from Reuters. However, it always come back as blank.
my codes are like this:
from bs4 import BeautifulSoup as bs
import requests
import re
url = 'https://www.reuters.com/markets/companies/TSLA.OQ/key-metrics/price-and-volume'
page = requests.get(url)
bs1 = bs(page.text, 'html.parser')
beta=bs1.find_all('th', class_ ='text__text__1FZLe text__dark-grey__3Ml43 text__regular__2N1Xr text__body__yKS5U body__base__22dCE body__body__VgU9Q',text=re.compile('Beta'))
print(beta)
I know it is not correct but I cannot figure out what to do. please help. Ultimate I want to be extract the Beta info for a stock from Reuters. thank you for your help!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是收集所需数据的一种方法:
这将返回:
Here's one way of collecting the data you need:
This will return:
您可以使用我以前的答案中的BS4刮擦网站(无需检查JavaScript/JSON),但您可以使用Seleniums功能。
这将返回:
You can scrape the site (without inspecting the javascript/json) using Selenium, using bs4 from my previous answer but you can use seleniums functions instead.
This will return: