use selenium

1. Install Google Chrome
2. Install Google Chrome Driver
3. Install the selenium package
4. Test
 
 
1. Install Google Chrome
 
2. Install Google Chrome Driver
 
Check your chrome browser version, select the corresponding driver version according to your browser version, download, http://chromedriver.storage.googleapis.com/index.html
After downloading and unzipping,
Copy the driver files to the /usr/bin directory in Ubuntu
In Windows, it can be placed directly in the file directory where the *.py that calls the browser is located
 
echo $PATH to view environment variables
Put the driver directly under the environment variable
 
3. Install the selenium package
Install with pycharm
After installation,
Environment variables to set the webdriver.py path in Windows
D:\biancheng\work\crawler_py3_zzl\Lib\site-packages\selenium\webdriver\firefox
Otherwise from selenium import webdriver cannot find webdriver module
 
4. Test
if __name__ == '__main__':
    # create browser
    driver = webdriver.Chrome()
    # request url
    driver.get(url)
    # save snapshot
    # driver.save_screenshot('baidu.png')
    # Common positioning
    el=driver.find_element_by_id('kw')
    print(el.get_attribute('value'))

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325211126&siteId=291194637