为什么我不能在BeautifulSoup上应用功能

时间:2018-07-07 08:01:39

标签: python python-3.x beautifulsoup request

在抓取网站后,我曾经应用过功能find_all 但不能再次申请

为什么?

>>> 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  

2 个答案:

答案 0 :(得分:0)

我认为您需要循环遍历find_all:

for div in soap.find_all("div")

答案 1 :(得分:0)

使用

for divs in MAIN_DATA:
    divs.find(SOMETHING)