Skip to content Skip to sidebar Skip to footer

How To Combine This Command With The Existing One?

From this answer, I know how to combine many similar commands for match in soup.find_all('div', {'class' : in the following code import requests from bs4 import BeautifulSoup url

Solution 1:

Use # in your CSS selector (div#videos will select all <div> with id=videos):

for tag in soup.select('''
        script,
        .hcdcrt,
        #ad_contentslot_1,
        #ad_contentslot_2,
        div.copyright,
        div.example-info,
        div.share-overlay,
        div.popup-overlay,

        div#videos
        '''):
    tag.extract()

More on CSS selectors here.

Post a Comment for "How To Combine This Command With The Existing One?"