第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用python從網(wǎng)站實時獲取一些數(shù)據(jù)?

如何使用python從網(wǎng)站實時獲取一些數(shù)據(jù)?

翻閱古今 2023-10-10 14:48:56
我想從網(wǎng)站獲取一些數(shù)據(jù)https://web.sensibull.com/optionchain?expiry=2020-03-26&tradingsymbol=NIFTY我正在使用 beautifulsoup 庫來獲取這些數(shù)據(jù),并嘗試了以下代碼:import requestsimport urllib.requestimport timefrom bs4 import BeautifulSoupurl = '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。無法獲取此數(shù)據(jù)并繼續(xù)我的工作。請幫忙。
查看完整描述

2 回答

?
米脂

TA貢獻1836條經(jīng)驗 獲得超3個贊

如果您正在尋找代碼。這可能有幫助:-


from selenium import webdriver 

import time

webpage = 'https://web.sensibull.com/optionchain?expiry=2020-03-26&tradingsymbol=NIFTY'

driver = webdriver.Chrome(executable_path='Your/path/to/chromedriver.exe') 

driver.get(webpage)

time.sleep(10)

nifty_fut = driver.find_element_by_xpath('//*[@id="app"]/div/div[4]/div[2]/div[3]/div/div/div[2]/div[1]/div[1]/div/button/span[1]/div[1]')

print(nifty_fut.text)

atm_iv = driver.find_element_by_xpath('//*[@id="app"]/div/div[4]/div[2]/div[3]/div/div/div[2]/div[1]/div[2]')

print(atm_iv.text)

driver.quit()


查看完整回答
反對 回復(fù) 2023-10-10
?
拉莫斯之舞

TA貢獻1820條經(jīng)驗 獲得超10個贊

可能是語法問題嘗試soup.find_all("div", class_="style__AtmIVWrapper-idZNMX kUMMRI")或只是soup.find("div", class_="style__AtmIVWrapper-idZNMX kUMMRI")


查看完整回答
反對 回復(fù) 2023-10-10
  • 2 回答
  • 0 關(guān)注
  • 120 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號