代码
代码很简单,主要是为了熟悉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!' |
补充:如何刷新当前页面
使用调用webdriver中刷新页面的方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# coding=utf-8 import time from selenium import webdriver driver = webdriver.Chrome() driver.maximize_window() driver.implicitly_wait( 6 ) driver.get( "https://www.baidu.com" ) time.sleep( 2 ) try : driver.refresh() # 刷新方法 refresh print ( 'test pass: refresh successful' ) except Exception as e: print ( "Exception found" , format (e)) driver.quit() |
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:https://segmentfault.com/a/1190000016852345