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

Selenium code example for regularly refreshing web pages

不言
Release: 2018-11-15 13:54:41
forward
3252 people have browsed it

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!'
Copy after login

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!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template