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

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

BeautifulSoup find() takes no keyword arguments 錯誤

BeautifulSoup find() takes no keyword arguments 錯誤

海綿寶寶撒 2023-03-22 16:08:52
from bs4 import BeautifulSoupfrom selenium import webdriverimport time import sysquery_txt = input("???? ?? ?? :")path = "C:\Temp\chromedriver_240\chromedriver.exe"driver = webdriver.Chrome(path)driver.get("https://www.naver.com")time.sleep(2)driver.find_element_by_id("query").send_keys(query_txt)driver.find_element_by_id("search_btn").click()driver.find_element_by_link_text("??? ???").click()full_html = driver.page_sourcesoup = BeautifulSoup(full_html, 'html.parser')content_list = soup.find('ul', id='elThumbnailResultArea')print(content_list)content = content_list.find('a','sh_blog_title _sp_each_url _sp_each_title' ).get_text()print(content)for i in content_list:       con = i.find('a', class_='sh_blog_title _sp_each_url _sp_each_title').get_text()    print(con)    print('\n')我在觀看在線學(xué)習(xí)時輸入了這段代碼,但在循環(huán)中它總是出錯。con = i.find('a', class_='sh_blog_title _sp_each_url _sp_each_title').get_text() 這一行顯示錯誤 'find() 沒有關(guān)鍵字參數(shù)'
查看完整描述

2 回答

?
慕桂英3389331

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

問題是,您必須使用.find_all()來獲取所有<a>標(biāo)簽。.find()只返回一個標(biāo)簽(如果有的話):


import requests

from bs4 import BeautifulSoup



url = 'https://search.naver.com/search.naver?query=tree&where=post&sm=tab_nmr&nso='

full_html = requests.get(url).content


soup = BeautifulSoup(full_html, 'html.parser')

content_list = soup.find_all('a', class_='sh_blog_title _sp_each_url _sp_each_title' )

? ??

for i in content_list:

? ? print(i.text)

? ? print('\n')

查看完整回答
反對 回復(fù) 2023-03-22
?
ABOUTYOU

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

改用.find('a', attrs={"class": "<Class name>"})。


查看完整回答
反對 回復(fù) 2023-03-22
  • 2 回答
  • 0 關(guān)注
  • 477 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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