Selenium error message “selenium.webdriver has no attribute execute script”

前端 未结 3 737
北恋
北恋 2021-01-13 23:24

I am using selenium to scrape an infinite scrolling page.

I am trying to use this code:

import time
import pandas as np
import numpy as np

from sele         


        
3条回答
  •  花落未央
    2021-01-13 23:37

    To make it work you have to create an instance of webdriver, e.g.:

    from selenium import webdriver
    
    driver = webdriver.Chrome() # webdriver.Ie(), webdriver.Firefox()...
    last_height = driver.execute_script("return document.body.scrollHeight")
    

    You can download Chromedriver from here

    You also need to add path to Chromedriver to your environment variable PATH or just put downloaded file into the same folder as your Python executable...

提交回复
热议问题