selenium安装
去官网下载一个jar包,然后运行:java -jar selenium-server-standalone-2.53.1.jar
然后写代码就行了,会打开一个浏览器窗口。看看有办法静默打开不,好像phantomjs模式可以,这个还要安装。
# coding: utf-8
# from selenium import selenium
from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.phantomjs.webdriver import WebDriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
browser = webdriver.Firefox()
# browser = WebDriver()
browser.get('http://baidu.com/')
print browser.title
f = browser.find_element_by_id('kw')
f.send_keys(u'谷歌')
f = browser.find_element_by_id('su')
f.click()
WebDriverWait(browser, 10).until(EC.title_contains(u"谷歌"))
print browser.title
# browser.quit()
上一篇: CodeMirror sql补全的关键字排序
下一篇: mac 安装bochs
0 Responses so far.