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

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

Python 分解類 BS4

Python 分解類 BS4

翻翻過去那場雪 2023-01-04 13:30:59
我在按類刪除標(biāo)簽時遇到問題,這是我的腳本:from bs4 import BeautifulSoupdef description_filter(description):    soup = BeautifulSoup(description, "lxml")    for span in soup.select('.akj-description-price'):        print(span)        print(soup)        span.decompose()    unwrapElements(soup, "html")    unwrapElements(soup, "body")    return soupdef unwrapElements(soup, elementsToFind):    elements = soup.find_all(elementsToFind)    for element in elements:        element.unwrap()description_filter(str)print(str)它的查找跨度但不是從湯中刪除......我做錯了什么?
查看完整描述

1 回答

?
達(dá)令說

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

它實(shí)際上從你的湯中去除了 span 但你并沒有改變你的str價(jià)值而是打印舊的。所以你沒有認(rèn)出它。如果您想str在某些操作后更改您的設(shè)置,只需更改description_filter(str)為


str = description_filter(str)

print(str) // will print new str without span class akj-description-price


查看完整回答
反對 回復(fù) 2023-01-04
  • 1 回答
  • 0 關(guān)注
  • 127 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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