1

how can I scroll more interests window? I used the below code to reach all (more interests) company information, it doesn't work.

    element=driver.find_element_by_xpath("//div[@class='artdeco-modal artdeco-modal--layer-default  pv-interests-modal pv-profile-detail__modal--no-padding pv-profile-detail__modal pv-profile-detail__modal--v2']")
       
    element.send_keys(Keys.END)

Also the code driver.execute_script("window.scrollTo(0, Y)") runs on main page, not more interests page

esra
  • 11
  • 1
  • Do not use words "doesn't work" to describe your problem. Please add a detailed description of what went wrong with your current approach – DonnyFlaw Jan 19 '21 at 17:17
  • [This](https://github.com/austinoboyle/scrape-linkedin-selenium) module might help you with LinkedIn scrapping. I found out about it in this [question](https://stackoverflow.com/questions/65531036/adding-an-open-close-google-chrome-browser-to-selenium-linkedin-scraper-code/65535170#comment115933115_65535170). It has arguments to adjust the scroll length. You can refer the code itself as it's pretty much simplistic. – Ananth Jan 19 '21 at 17:43

2 Answers2

1

You better use Pyautogui, it is a library to automate your mouse & keyboard movement.

I used this approach for the same problem. This question can also help you if you don't want to use Pyautogui

Dharman
  • 30,962
  • 25
  • 85
  • 135
0

There is a keyboard shortcut for scrolling that is, visit a web page and just enter the space key. The same thing you can implement in selenium.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep

scroll = 2 # how many times space key to be pressed to reach the end
for i in range(scroll):
    driver.find_element_by_tag_name("html").send_keys(Keys.SPACE)
    sleep(1)

Earlier I tried with "END" key also, but that time lost some data that is why i am using sleep over each scroll.

arun n a
  • 684
  • 9
  • 26
  • Refer: https://github.com/arun-n-a/linkedin-ppl-search-scraper/blob/master/person_current.py demo video: https://www.linkedin.com/posts/arun-saanthi_python3-selenium-automations-activity-6656001728028176384-YumL/ – arun n a Jul 04 '21 at 10:31