我想从网站获取一些数据
https://web.sensibull.com/optionchain?expiry=2020-03-26&tradingsymbol=NIFTY
我正在使用 beautifulsoup 库来获取这些数据,并尝试了以下代码:
import requests
import urllib.request
import time
from bs4 import BeautifulSoup
url = 'https://web.sensibull.com/optionchain?expiry=2020-03-26&tradingsymbol=NIFTY'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
b = soup.find("div", {"class": "style__AtmIVWrapper-idZNMX kUMMRI"})
print(b)
但它显示“无”作为输出。
虽然在完整的 HTML 代码中只有一个这个名称的类,但我也尝试过:
for b in soup.find_all('div', attrs={'class':'style__AtmIVWrapper-idZNMX kUMMRI'}):
print(b.get_text())
print(len(b))
但这不起作用。
还尝试了 soup.find("div") 但它没有在输出中显示所需的 div 标签,可能是由于存在嵌套的 div。
无法获取此数据并继续我的工作。请帮忙。
米脂
拉莫斯之舞
相关分类