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

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

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

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

HUX布斯 2022-09-13 17:40:04
我想從網(wǎng)站上獲取數(shù)據(jù)https://web.sensibull.com/optionchain?expiry=2020-03-26&tradingsymbol=NIFTY我正在使用美圖庫來獲取此數(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 回答

?
哈士奇WWW

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

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


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()


查看完整回答
反對 回復 2022-09-13
?
吃雞游戲

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

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

如果對網(wǎng)頁抓取和bs4感興趣,請查看文檔 https://www.crummy.com/software/BeautifulSoup/bs4/doc/#find


查看完整回答
反對 回復 2022-09-13
  • 2 回答
  • 0 關注
  • 112 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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