Because do not want to use URLLIB2, have not used splinter, today want to try, after all, the latter support more user-friendly features/automation.
1, install splinter
The installation process is simple and the PIP is installed to execute:
$ [sudo] pip install splinter
or go to Splinter's GitHub page, download the source code (link address:https://github.com/cobrateam/splinter), and then execute:
$ git clone git://github.com/cobrateam/splinter.git$ CD splinter$ [sudo] python setup.py install
The dependent libraries that are required during installation are automatically downloaded without fear.
2, install Chromedriver
Because I need chrome to support the page test, I need to install chromedriver. The installation process is simple (actually no need to install), note the next version, some of the lower version is not supported by the high version of Chrome. Image link: http://npm.taobao.org/mirrors/chromedriver.
I just threw chromedriver.exe in the c/windows/system32/folder, so I didn't need to configure the environment variable.
Then I wrote the first line "Hello World", the code is as follows:
#-*-Coding:utf-8-*-import sysfrom splinter.browser import browserreload (SYS) sys.setdefaultencoding (' UTF8 ') encoding = Lambda X:x.encode (' gbk ') browser = browser (driver_name= "Chrome") browser.visit ("https://www.baidu.com") print Encoding ("test page:" + browser.title) browser.quit ()
Run for a moment and quote the following information:
Error message: "' chromedriver ' executable needs to being available in the path"
Did I forget to add the Chromedriver.exe to path? But I thought it was wrong. Because I put chromedriver.exe directly under the c/windows/system32/folder, it is not necessary to add the path in path. For the sake of prudence, I added "c/windows/system32;" (stupid enough) in path. But a running error is still.
I simply gave up path at the back, I used absolute path reference, the error is still. Restart? It's still not working. On the StackOverflow checked, there are many people who have this problem, but most of the answers are suggested using absolute paths, which does not solve my problem. Just as I gave up splinter, loaded selenium , I suddenly thought, put Chromedriver.exe under script to try? Sure enough, I put the chromedriver.exe and my test. PY on the same path, and it's no problem to run them.
Remember, lest you forget.
Errors encountered when building Splinter+python environment