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

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

從標(biāo)簽中檢索內(nèi)容

從標(biāo)簽中檢索內(nèi)容

九州編程 2021-09-11 10:28:27
在我之前的一篇文章中,我能夠檢索所有 p 標(biāo)簽import bs4from urllib.request import  urlopen as uReqfrom bs4 import BeautifulSoup as soupmy_url='https://www.centralpark.com/things-to-do/central-park-zoo/polar-bears/'# opening up connectionuClient = uReq(my_url)page_html = uClient.read()# close connectionuClient.close()page_soup = soup(page_html, features="html.parser")ps=list(page_soup.find_all('p'))for s in ps:    print(s)我想要的是檢索這些 p 標(biāo)簽中的任何內(nèi)容。前任:ex1='<p> this is example </p>' -> I want res1 = 'this is example' ex2='<p> this is <strong> nice </strong> example </p>' -> I want res2 = 'this is nice example' ex3='<p> this is <b> okeyish </b> example </p>' -> I want res3 = 'this is okeyish example'所有結(jié)果(res1,res2,res3)都可以進(jìn)入List。我已經(jīng)搜索了解決方案,但建議的解決方案只適用于一種類型的標(biāo)簽示例。我想要的只是檢索 p 和 /p 之間的所有內(nèi)容,無論它們之間出現(xiàn)哪些其他標(biāo)簽。如果那些其他標(biāo)簽有內(nèi)容,那些也應(yīng)該包括在內(nèi)。
查看完整描述

1 回答

?
紅糖糍粑

TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超6個(gè)贊

ps=page_soup.find_all('p')


results = []

for s in ps:

    #print(s.text)

    results = results.append(s.text)


查看完整回答
反對 回復(fù) 2021-09-11
  • 1 回答
  • 0 關(guān)注
  • 186 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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