亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

無法理解的解析器行為

無法理解的解析器行為

長風秋雁 2022-10-06 16:56:35
請幫幫我!我編寫了一個簡單的解析器,但它不能正常工作,我不知道這與什么有關。import requestsfrom bs4 import BeautifulSoupURL = 'https://stopgame.ru//topgames'HEADERS = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0', 'accept': '*/*'}HOST = 'https://stopgame.ru'def get_html(url, params=None):    r = requests.get(url, headers=HEADERS, params=params)    return rdef get_content(html):    soup = BeautifulSoup(html, 'html.parser')    items = soup.find_all('a', class_="lent-block game-block")    print(items)def parse():    html = get_html(URL)    if html.status_code == 200:        items = get_content(html.text)    else:        print('Error')parse()我有這個輸出:[]Process finished with exit code 0
查看完整描述

1 回答

?
慕娘9325324

TA貢獻1783條經驗 獲得超4個贊

items = soup.find_all('a', class_="lent-block game-block")

您正在嘗試找出 html 中實際上不存在的錨標記的“lent-block game-block”類,因此您得到的是空白列表。

嘗試使用此 div 項目,您將獲得匹配項目的列表。

items = soup.find_all('div', class_="lent-block lent-main")


查看完整回答
反對 回復 2022-10-06
  • 1 回答
  • 0 關注
  • 97 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號