Python数字驱动
Posted 下辈子做一只猫
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python数字驱动相关的知识,希望对你有一定的参考价值。
#练习1:打开3个网址,每个等3秒钟
urls.txt:
http://www.baidu.com
http://www.sogou.com
http://www.sohu.com
main.py:
from selenium import webdriver
import time
driver = webdriver.Chrome(executable_path = "c:\chromedriver")
with open("urls.txt") as fp: #urls.txt里存三个网址
for url in fp:
driver.get(url)
time.sleep(3)
driver.current_url
driver.quit()
1 #练习2:通过命令行选择浏览器或文件打开和执行 2 urls.txt: 3 http://www.baidu.com 4 http://www.sogou.com 5 http://www.sohu.com 6 7 main.py: 8 #python test.py chrome http://www.sohu.com 9 #python test.py ie urls.txt 10 11 from selenium import webdriver 12 import sys 13 import time 14 15 if len(sys.argv)!=3: 16 print "parameter number is not valid!" 17 sys.exit() 18 19 browser_type=sys.argv[1] 20 file_or_url=sys.argv[2] 21 22 if browser_type.lower()=="chrome": 23 driver = webdriver.Chrome(executable_path = "c:\chromedriver") 24 elif browser_type.lower()=="ie": 25 driver = webdriver.Ie(executable_path = "c:\IEDriverServer") 26 else: 27 driver = webdriver.Firefox(executable_path = "c:\geckodriver") 28 29 if file_or_url.find("http://")!=-1: 30 driver.get(file_or_url) 31 else: 32 with open(path) as fp: #urls.txt里存三个网址 33 for url in fp: 34 driver.get(url) 35 time.sleep(3) 36 driver.current_url 37 driver.quit()
以上是关于Python数字驱动的主要内容,如果未能解决你的问题,请参考以下文章
关于mysql驱动版本报错解决,Cause: com.mysql.jdbc.exceptions.jdbc4Unknown system variable ‘query_cache_size(代码片段