本文摘自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基础点介绍
Python去重函数是什么
Python实现翻译软件
Python中descriptor的详细介绍
Python文件和流相关知识介绍
Python动态爬虫的实例分享
k-means算法在Python中的实现
Python网络编程之tcp套接字的简单用法
Python之中的迭代与迭代对象是什么?
Python集合有序吗
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » Selenium定时刷新网页的代码示例