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

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

如何獲得Python導(dǎo)航到鏈接并從此子鏈接打印多個數(shù)據(jù)點?

如何獲得Python導(dǎo)航到鏈接并從此子鏈接打印多個數(shù)據(jù)點?

白板的微信 2021-05-30 00:15:21
我正在查看的是父URL。https://en.wikipedia.org/wiki/List_of_current_members_of_the_United_States_Senate從那里,我想讓Python單擊幾個鏈接,所有鏈接都是('td')[3] .a ['href']。父 URL 中的前三個是: 'Richard Shelby', 'Doug Jones', and 'Lisa Murkowski'。所有子鏈接都有與此匹配的文本: 'Assumed office'。我想抓住所有這些日期'Assumed office'。因此,因為'Richard Shelby'它將是:Assumed officeJanuary 3, 1987Assumed officeApril 10, 2018我怎樣才能做到這一點?對于導(dǎo)航到幾個不同的鏈接,我認(rèn)為它將看起來像這樣...from urllib.parse import urljoinsenator_link = "https://en.wikipedia.org/wiki/List_of_current_members_of_the_United_States_Senate"senator_link = row.find_all('td')[3].a['href']senator_link = urljoin(link, senator_link)response = session.get(senator_link)with requests.Session() as session:    html = session.get(link).text    soup = BeautifulSoup(response.content, "lxml")    res = soup.findAll("span", {"class": "nowrap"})    for r in res:        print("Assumed Office: " + r.find("span", {'class': 'nowrap'}).text)我得到的那段代碼是這樣的:AttributeError: 'NoneType' object has no attribute 'text'
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 156 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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