本文摘自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能开发ios与安卓吗
Python环境下如何配置pydev插件
Python中for是什么
关于Python中原始字符串与unicode字符串操作符的实例
Python头文件怎么写
Python实现一键多值字典的方法实现
Python中线程的mq消息队列实现及优缺点介绍
Python针对任意多的分隔符拆分字符串(附代码)
Python 读取dicom头文件的实例
Python自定义对象实现切片功能的介绍(代码示例)
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » Selenium定时刷新网页的代码示例