我正在尝试用python和selenium编写一些博客。在
但是,源页面仅限于几篇文章,因此我需要向下滚动以加载AJAX。。在
有没有一种方法可以在一次调用selenium时获得完整的源代码?在
代码应该是:
# url and page source generating
url = url_constructor_medium_news(blog_name)
content = social_data_tools.selenium_page_source_generator(driver, url)
try:
# construct soup
soup = BeautifulSoup(content, "html.parser").rss.channel
# break condition
divs = soup.find_all('item')
except AttributeError as e:
print(e.__cause__)
# friendly
time.sleep(3 + random.randint(1, 5))
我不相信有一种方法可以用卸载的数据填充驱动程序,否则这些数据将通过滚动获得。在
获取数据的另一种解决方案是
driver.execute_script("windows.scrollTo(0, document.body.scrollHeight);")
我以前用this作为参考。在
我希望这有帮助!在
相关问题 更多 >
编程相关推荐