本文摘自php中文网,作者不言,侵删。
本篇文章给大家带来的内容是关于Selenium定时刷新网页的代码示例,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
代码
代码很简单,主要是为了熟悉Selenium这个库的函数.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | from selenium import webdriver
import time
import random
url = raw_input( 'Input your website:' ).strip()
num = int(raw_input( 'How much times do you want:' ),10)
options = webdriver.FirefoxOptions()
options.add_argument( '--headless' )
browser = webdriver.Firefox(firefox_options=options)
browser.get(url)
print 'Please wait...'
for i in range(num):
i += 1
print 'Refresh +%d' %i
time.sleep(random.randint(1,3))
browser.refresh()
browser.quit()
print 'Good Bye!'
|
以上就是Selenium定时刷新网页的代码示例的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
Python中x[::]什么意思
Python read lines() 有什么用?能用在什么地方?
Python如何生成随机密码?
Python字符串格式化什么意思
如何用Python整理附件
学Python下什么软件
Python源程序执行的方式有什么
Python 类对象和实例对象动态添加方法
Python中集合可变吗
Python有哪些需要学习的知识?
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » Selenium定时刷新网页的代码示例