dimension
dimension

Reputation: 1030

Why i can't apply function on BeautifulSoup

After scraping website I once applied the function find_all But cannot apply once more

why?

>>> from requests import get
>>> with get(url) as conn:
        print(conn)
>>> soap = BeautifulSoup(conn.content,"lxml")
>>> MAIN_DATA = soap.find_all("div",{"class" :"SOMETHING"})
>>> MAIN_DATA.find(SOMETHING) # WHY I CANNOT APPLY find and findall Function to this object

                 THANKS  

Upvotes: 1

Views: 58

Answers (2)

Shashank Singh
Shashank Singh

Reputation: 657

Use

for divs in MAIN_DATA:
    divs.find(SOMETHING)

Upvotes: 1

Nicolas Talichet
Nicolas Talichet

Reputation: 311

I think you need to loop on your find_all:

for div in soap.find_all("div")

Upvotes: 1

Related Questions