使用Python在Web取消过程中未显示的跨度标签中的数字值?
我是网络刮擦的新手。
我正在尝试从
我的代码是:
import requests
from bs4 import BeautifulSoup as bs
url = 'https://www.dailyfx.com/sentiment'
all_pages_reviews = []
response = requests.get(url)
soup = bs(response.content, 'html.parser')
rev_div = soup.findAll("span",attrs={"class","dfx-rateDetail__percentageInfoText font-weight-bold"})
print(rev_div)
这给出了Rev_div为“ bs4.element.ResultSet”,以下输出:
</span>, <span class="dfx-rateDetail__percentageInfoText font-weight-bold" data-market-id="GBPUSD" data-sort-column="sentiment-long" data-stream-type="sentiment" data-type="long-value-info" data-value="--">
</span>, <span class="dfx-rateDetail__percentageInfoText font-weight-bold" data-market-id="FR40" data-sort-column="sentiment-short" data-stream-type="sentiment" data-type="short-value-info" data-value="--">
问题是而是数字值' - ' 'data_value'。
我的目标是根据“ data-market-id”('gbpusd','fr40')找到“数据值”。
任何潜在客户都将不胜感激。
I am new to web scraping.
I am trying to download the Net Long position from https://www.dailyfx.com/sentiment site. The value is situated in div with class 'dfx-technicalSentimentCard__netLongContainer' and span attribute 'data-value'.
My code is:
import requests
from bs4 import BeautifulSoup as bs
url = 'https://www.dailyfx.com/sentiment'
all_pages_reviews = []
response = requests.get(url)
soup = bs(response.content, 'html.parser')
rev_div = soup.findAll("span",attrs={"class","dfx-rateDetail__percentageInfoText font-weight-bold"})
print(rev_div)
This gives rev_div as "bs4.element.ResultSet" with following output:
</span>, <span class="dfx-rateDetail__percentageInfoText font-weight-bold" data-market-id="GBPUSD" data-sort-column="sentiment-long" data-stream-type="sentiment" data-type="long-value-info" data-value="--">
</span>, <span class="dfx-rateDetail__percentageInfoText font-weight-bold" data-market-id="FR40" data-sort-column="sentiment-short" data-stream-type="sentiment" data-type="short-value-info" data-value="--">
The problem is instead of a numeric value '--' is shown for 'data_value'.
My goal here is to find 'data-value' as per 'data-market-id' ('GBPUSD', 'FR40').
Any lead will be highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论