-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebfresh.py
More file actions
executable file
·34 lines (31 loc) · 1.31 KB
/
webfresh.py
File metadata and controls
executable file
·34 lines (31 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time,os,argparse,sys
from random import randint
from selenium import webdriver
#chrome browser driver: http://chromedriver.storage.googleapis.com/index.html
def parse_args():
parser = argparse.ArgumentParser(usage="""python %(prog)s -u url [-n num]""")
parser.add_argument('-u',dest='url',metavar='url',help="web link need to fresh.")
parser.add_argument('-n',dest='num',metavar='num',type=int,default=200,help="fresh times, default: %(default)s.")
return parser
def refresh(url,num):
driver = webdriver.Chrome("/mnt/c/software/chrome/chromedriver.exe")
driver.get(url)
for i in range(num):
print "\r",
print "refresh progress: {} time ......".format(i+1),
sys.stdout.flush()
time.sleep(randint(30,90))
driver.refresh()
driver.close()
if __name__ == "__main__":
parse = parse_args()
args = parse.parse_args()
# Do not set Required =True, and print the complete help information without required parameters
if not args.url:
parse.print_help()
sys.exit()
print('\rstart time: [%s]' % time.strftime( "%Y-%m-%d %H:%M:%S", time.localtime(time.time())))
refresh(args.url,args.num)
print('\nend time: [%s]' % time.strftime( "%Y-%m-%d %H:%M:%S", time.localtime(time.time())))