Home >Backend Development >Python Tutorial >Selenium code example for regularly refreshing web pages

Selenium code example for regularly refreshing web pages

不言
不言forward
2018-11-15 13:54:413256browse

The content of this article is about the code example of Selenium regularly refreshing the web page. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Code

The code is very simple, mainly to familiarize yourself with the functions of the Selenium library.

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!'

The above is the detailed content of Selenium code example for regularly refreshing web pages. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete