我想从这个网站上提取一个数字
http://www.mycryptobuddy.com/BitcoinMiningCalculator
我试图使用beautifulsoup在一个输入字段中提取这个数字,其中显示“3511.0”(如图所示),但是这在html中是不可见的。你知道吗
我怎样才能用beautifulsoup提取这个数字?你知道吗
我的代码:
from urllib import request
from bs4 import BeautifulSoup
html = 'http://www.mycryptobuddy.com/BitcoinMiningCalculator'
page = request.urlopen(html)
soup = BeautifulSoup(page, 'html.parser')
dif = soup.find('input', attrs={'ng-model': 'difficulty'})
print(dif.get('value'))
print(dif.attrs)
输出:
None
{'type': 'number', 'ng-model': 'difficulty', 'ng-change': 'computeProfits(); turnAutoUpdateOff()'}
Process finished with exit code 0
在html中找不到这个数字的原因是它不在那里,它是通过javascript通过位于ws://185.185.40.128:1235的websocket接收到的/套接字.io/ 正如你在这张图片上看到的:![](https://i.stack.imgur.com/CTMcz.jpg)
如果你想得到这些数字,你应该连接到websocket,并解析传入的消息。你知道吗
相关问题 更多 >
编程相关推荐