美文网首页
BeautifulSoup 过滤文本

BeautifulSoup 过滤文本

作者: lifeLL | 来源:发表于2019-06-25 04:10 被阅读0次
    <a class="t ac_linkurl" href="https://jumpzhineng.58.com/jump?target=pZwY0ZnlszqBpB3draOWUvYfpZRG0v6fIit1P1bQnjTQnWTQnHbQnL980v6YUykKuadBPADOmHEdmzdWuyE1sHwbP1EVrH-WPid-mvEOPjE1nWu6m1mKPHbOnWbdPWbknj01P10KTHnLrHDknjDznjDQrHD1THD3nTDQrjTKP1bdPkDQTHDdPWDYnjmLrjNOPH0KnE7-0dqkmdqC0dqzpyICITDQTHDKUARMUdqzuyPfURqQuMPxugPx0hRWXyP_ugkQsARz0v6fIgwMg1cknH0krHTYgvR30ZkQTiYQTEDkTHTKTHDKuHbzrHubrAmVrHbzuiYYuWwbsyD3nvnVPAnLPW--myndPHFhTHEzPH9OnW0QTHcLPj0vPWc1n193n1bzrTDKPH9kTHDKna3dnHm3PjnYnWDkrHbdPjDzTEDVTEDKpZwY0ZnlszqBpB3draOWUvYfpgKCUvO-0vCf0A3Qsk7-rjIzyhkkNbQRwNDzn7w-E-RHib7M5HYKnHDzsWbvsWDOPz3QnjDKnTDkTEDLnjDznzkQnjnKXLYKnEDQnjTknHTvTHuhnvnYm1F6sHu-uynVPjN3nzYOn1E3syu-PH66m1wBnjnOPTDKnTDKTHTKnikQnHEzsjm3n1EKPHubnj0YPWcOmWNduyDQP9&amp;adact=3&amp;link_abtest=&amp;psid=157345112204656710249551958&amp;slot=1000106" name="37910012011913" onclick="clickLog('from=pc_list_iphonesj_xinxi_adinfo_bj');" rel="nofollow" target="_blank" tongji_label="listclick">中欣卡商通卡福卡家乐福美通卡京客隆欧尚卡京东卡
                                                            <span class="tu">[1图]</span>
    <span class="jingpin">精</span>
    </a>
    
        for i in hrefs_list:
            print(i)
            # print(i.text.strip())
            # print(type(i.text))
            print([text.strip() for text in i.find_all(text=True) if text.parent.name != 'span' and text.strip()])
          这样判断即可以把span标签里面的文本过滤掉,yes
    

    相关文章

      网友评论

          本文标题:BeautifulSoup 过滤文本

          本文链接:https://www.haomeiwen.com/subject/solzqctx.html