Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Selenium为媒体rss提要编写脚本_Python_Selenium_Selenium Webdriver - Fatal编程技术网

Python Selenium为媒体rss提要编写脚本

Python Selenium为媒体rss提要编写脚本,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,我正在尝试用python和selenium编写一些博客 但是,源页面仅限于几篇文章,因此我需要向下滚动以加载AJAX 有没有一种方法可以通过selenium在一次调用中获得完整的源代码 代码类似于: # url and page source generating url = url_constructor_medium_news(blog_name) content = social_data_tools.selenium_page_source

我正在尝试用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_脚本(“windows.scrollTo(0,document.body.scrollHeight))

我以前用过作参考

我希望这有帮助