Skip to content

Instantly share code, notes, and snippets.

@arseniyturin
Last active May 31, 2020 20:47
Show Gist options
  • Save arseniyturin/f6224ce558c9663fcce5592051e1a15f to your computer and use it in GitHub Desktop.
Save arseniyturin/f6224ce558c9663fcce5592051e1a15f to your computer and use it in GitHub Desktop.
Get usernames who liked the post
# emulate click on a likes button
driver.execute_script('''document.getElementsByClassName('Nm9Fw')[0].lastElementChild.click()''')
# scroll down by 4000px to load more users who liked the post
driver.execute_script('''document.getElementsByClassName('Igw0E IwRSH eGOV_ vwCYk i0EQd')[0].firstChild.scrollBy(0, 4000);''')
time.sleep(0.2)
# collect usernames
usernames = driver.execute_script('''return document.getElementsByClassName('_7UhW9 xLCgt MMzan KV-D4 fDxYl');''')
# each username sits inside of a div, so to get actual username we can use .get_attribute() method
usernames[0].get_attribute('innerText')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment