0
有人請向我解釋爲什麼我運行此代碼時得到空白返回?我只是試圖用美麗的湯打印html標籤的內容。代碼如下。Web刮 - 空白返回
感謝
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
from bs4 import BeautifulSoup
http = urllib3.PoolManager()
def stats():
url = 'https://www.flashscore.com.au/football/usa/mls/results/'
response = http.request('GET', url)
soup = BeautifulSoup(response.data,'lxml')
right_table=soup.find('div',{'class':'fs-table tournament-page'})
print(right_table.text)
stats()
的問題是,該網頁被客戶端渲染,所以div最初沒有內容。需要不同的技術:https://stackoverflow.com/questions/2148493/scrape-html-generated-by-javascript-with-python –
頁面使用JavaScript和WebSocket來加載和獲取並呈現數據。有關如何呈現它,請參閱我對https://stackoverflow.com/questions/45259232/scraping-google-finance-beautifulsoup/的回答。 –
@ Error-SyntacticalRemorse完成,謝謝你的提示 –