How to click on Load More button within Google Trends and print all the titles through Selenium and Python

前端 未结 4 1967
耶瑟儿~
耶瑟儿~ 2020-12-12 02:02

this time I would like to click a button in order to load more real-time searches. Here is the link of the website:

https://trends.google.com/trends/trendingsearches

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-12 02:45

    for scrolling down you can use this code :

    driver.execute_script("window.scrollTo(0, Y)")  
    

    where Y : is the vertical position you want to scroll to.(you can provide the value of Y as 100,200,300 as per your requirement).

    Once scroll down is done, you can use this code :

    load_more_button = WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH, "//div[@ng-click='ctrl.loadMoreFeedItems()']")))  
    load_more_button.click()
    

提交回复
热议问题