我正在尝试通过一个基本上是弹出窗口的网站注册页面进行解析。打开弹出窗口后,<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)