Python 请求无法读取孔网缝线
我正试图从这个网站获得一个跨度Python 请求无法读取孔网缝线,python,beautifulsoup,python-requests,Python,Beautifulsoup,Python Requests,我正试图从这个网站获得一个跨度 import requests from bs4 import BeautifulSoup source = requests.get('https://www.nbim.no/').text soup = BeautifulSoup(source, 'lxml') find = soup.find("span", id="liveNavNumber") print(find) 这就是我想要得到的。但是reqest不会阅读它。如果您查看页面的源代码(而不
import requests
from bs4 import BeautifulSoup
source = requests.get('https://www.nbim.no/').text
soup = BeautifulSoup(source, 'lxml')
find = soup.find("span", id="liveNavNumber")
print(find)
这就是我想要得到的。但是reqest不会阅读它。如果您查看页面的源代码(而不是屏幕截图所示的活动树),您可以看到只有
<span aria-live="off" id="liveNavNumber"></span><span class="currency">nok</span>
所以,如果你对这个值感兴趣,你可以
>>> import requests
>>> r = requests.get("https://www.nbim.no/LiveNavHandler/Current.ashx?l=en-GB")
>>> data = r.json()
>>> print(data["Value"])
10 253 757 444 193
>>>
>>> import requests
>>> r = requests.get("https://www.nbim.no/LiveNavHandler/Current.ashx?l=en-GB")
>>> data = r.json()
>>> print(data["Value"])
10 253 757 444 193
>>>