python simulation open Google browser and open the page (selenium + chrome)

The reason is that writing this blog because before all mass participation reptiles, but fortunately they will point website, crawl for some time feel tired heart, every time to find their own URL, find the law, passed headers.
Then I think to simulate the browser to do a variety of operations, and then decisively learn selenium, for the first time with a program to open the browser a little excited to come forward quickly taken down.
Get to the bar:
1. Install selenium (pip using the tool on the line, not more than that)
2. Review your chrome browser version, is to find the location of your chrome browser, then the first folder name is the corresponding version
3. Download chromedriver, link: http://chromedriver.storage.googleapis.com/index.html
Note: chromedriver to your chrome browser and correspond correspondence table is as follows:
chromedriver version Supported version of Chrome
v2.33 v60-62
v2.32 v59-61
v2.31 v58-60
v2.30 v58-60
v2.29 v56-58
v2.28 v55-57
v2.27 v54-56
v2.26 v53-55
v2.25 v53-55
4. Such preparatory work done directly on the code:
from selenium import webdriver
import os

chromedriver = "C:/Program Files (x86)/Google/Chrome/Application/chromedriver" 
os.environ["webdriver.chrome.driver"] = chromedriver
= webdriver.Chrome Driver (chromedriver) # simulate open the browser
 driver.get ( "https://www.baidu.com/" ) # Open URL
 driver.maximize_window () # window is maximized (it does not matter ha)
 driver.quit ()
The time to execute code to witness the miracle of it, the miracle had happened should never blame me, leave a message to continue the exchange.

Published 49 original articles · won praise 95 · Views 230,000 +

Guess you like

Origin blog.csdn.net/Trisyp/article/details/78688106