如何使用美丽的汤解析多个身体标签?

时间:2019-10-28 07:07:15

标签: python selenium-webdriver beautifulsoup xml-parsing

我正在尝试通过一个基本上是弹出窗口的网站注册页面进行解析。打开弹出窗口后,<body>变为<body class= modal-open>。我想通过<body class= modal-open>进行解析。请帮忙。我已经尝试了以下代码。

from bs4 import BeautifulSoup, SoupStrainer
from selenium import webdriver
driver.get("some site")
content = driver.page_source
while(loaded):
            state = driver.execute_script('return document.readyState')
            if state == 'complete':
                loaded = False #this is to stop the loop if the page completely loads with its js changes
                html2 = driver.execute_script("return document.documentElement.innerHTML;")
                soup = BeautifulSoup(html2, "lxml")
                body = soup.find_all('body', attrs={'class':['modal-open']})
                print(body)

0 个答案:

没有答案