什么生日的人有佛缘| 右边脑袋疼是什么原因| 虚岁31岁属什么生肖| 益生元和益生菌有什么区别| 什么是呆账| 葛洲坝集团是什么级别| 糖尿病人适合吃什么水果| 小候鸟是什么意思| 胆结石可以吃什么水果| xy是什么意思| 早上10点是什么时辰| 口腔溃疡可以吃什么| 什么是拉拉| 三点水加个有字念什么| 属鸡在脖子上戴什么好| cm是什么意思| 得逞是什么意思| 嗷呜是什么意思| 什么是失眠| 年少轻狂是什么意思| 心血不足吃什么药| 加盟资质需要什么条件| 蓬头垢面是什么意思| 卡鱼刺挂什么科| 手上为什么长湿疹| 灰指甲是什么症状| 舌苔白吃什么药| 鼻甲肥大吃什么药最好| 刺史相当于现在什么官| 中级职称是什么| a型血与o型血生的孩子是什么血型| 什么矿泉水最好| 得了幽门螺旋杆菌有什么症状| 谩骂是什么意思| 长智齿牙龈肿痛吃什么药| 梦见死人是什么征兆| 可以是什么意思| 孩子腿疼挂什么科| 即日是什么意思| bonnie是什么意思| 首套房有什么优惠政策| pda是什么意思| 脑血管痉挛是什么原因引起的| 如果你是什么那快乐就是什么| 霍山石斛有什么作用| 梦见财神爷是什么预兆| 三奇贵人是什么意思| 梦见好多南瓜是什么意思| 3.8号是什么星座| 大黄是什么药| 孩子感冒咳嗽吃什么药| 断眉有什么说法| 五行什么生木| 七杀大运是什么意思| 魂牵梦绕是什么意思| 口腔溃疡缺什么| 感冒吃什么药最快| 咽峡炎是什么病| 手麻挂什么科| 放疗有什么副作用| 移徒是什么意思| 性病有什么症状| 面黄肌瘦是什么意思| 嘚儿是什么意思| 什么样的山| 六十岁是什么之年| vjc是什么品牌| e代表什么方向| 仰面朝天是什么生肖| 吃了螃蟹后不能吃什么| 什么伤口需要打破伤风| 猴和什么属相最配| 女人左眼皮跳是什么预兆| 什么是生育津贴| 肚脐眼下面痛什么原因| 手指上的斗和簸箕代表什么意思| p是什么面料| gg 是什么意思| 低密度脂蛋白高有什么症状| 紫光檀是什么木| 不寐病是什么意思| 一竖一点念什么| 24D是什么激素| 穿什么衣服| 反酸烧心吃什么药效果好| 体育总局局长什么级别| 小米不能和什么一起吃| 昊字五行属什么| 早晨起来嘴苦是什么原因| 9.24是什么星座| 什么叫雷达| 小腹痛男性什么原因| 沙蒜是什么| 姨妈发黑量少什么原因| 痛风是什么原因引起的| 大专跟本科有什么区别| 洁面膏和洗面奶有什么区别| 摩羯座和什么星座最配| 丙肝是什么病严重吗| 胃不好吃什么养胃水果| 鞋油自然色是什么颜色| 肝阴虚吃什么中成药| 领英是什么| 子宫为什么长肌瘤| 心脏彩超主要检查什么| 双龙戏珠是什么意思| 钙化积分是什么意思| 六月十八是什么星座| 慢性结肠炎吃什么药好| 狼入虎口是什么意思| 病毒性肝炎有什么症状| 女人叫床最好喊什么| 调兵遣将是什么生肖| 动物园里有什么动物| 法国货币叫什么| 耋是什么意思| 河字五行属什么| 孕妇吃什么牌子奶粉| 高密度脂蛋白是什么| 机翻是什么意思| 疱疹有什么症状| jdk是什么| b12是什么| fu是什么| 中国第一长洞是什么| 脚癣用什么药最好| 低血糖是什么原因| 世界最大的岛是什么岛| 急性咽炎吃什么药| 香港代购什么东西好| 一月来两次月经是什么原因| 邮戳是什么意思| 被褥是什么| 脑部有结节意味着什么| 五心烦热是什么症状| mmi是什么药| 看病人带什么水果| timing是什么意思| 孕吐严重是什么原因| 尼泊尔属于什么国家| 血细胞分析是查什么的| 糖尿病患者可以吃什么水果| 梦见黑狗是什么意思| 催供香是什么意思| 淋巴细胞比率低是什么意思| 何妨是什么意思| 一个月一个屯念什么| 四月23日是什么星座| ards是什么病的简称| 孱弱是什么意思| 蚝油可以用什么代替| 什么冰淇淋最贵| 入党有什么好处| 二五八万是什么意思| 蜘蛛结网预示着什么| 脱氧核苷酸是什么| 大表哥是什么游戏| 吴亦凡为什么退出exo| 补气养阴是什么意思| 怀孕前三个月需要注意什么| 骨转移用什么药能治愈| 胃反酸水是什么原因| 地府是什么意思| 肝囊肿挂什么科| 胃胀气用什么药最好| 奄奄一息的息是什么意思| 出差什么意思| 什么的马| 王源粉丝叫什么| 舌头紫红色是什么原因| 注是什么意思| 诸君是什么意思| 什么是蛋白质| 过敏性结膜炎用什么药| 青的五行属性是什么| 迪化是什么意思| 为什么会突然得荨麻疹| 吃李子不能吃什么| 经常脚抽筋是什么原因| 促甲状腺素高是什么意思| 遇到黄鼠狼是什么征兆| 吃什么调节内分泌最快| 阿普唑仑片是什么药| 女人太瘦吃什么增肥| 白电油对人体有什么危害| 绝经什么意思| 想飞上天和太阳肩并肩是什么歌| 家里为什么不能放假花| 汉防己甲素片治什么病| 摩羯是什么星座| 怀孕初期需要注意些什么| b像什么| 男生为什么会勃起| 回盲肠在什么位置| 胃角在什么位置图片| 什么能软化血管| 仓鼠能吃什么东西| 蔓越莓有什么功效和作用| 大麦和小麦有什么区别| 小腿肿是什么原因| 怀孕几天后有什么反应| 健脾益气是什么意思| 依达拉奉注射功效与作用是什么| 淤青用什么药| 抽烟为什么会上瘾| 什么是腐女| 口嫌体正直是什么意思| 睡觉掉床下是什么预兆| 榴莲和什么水果相克| 护理专业是做什么的| 速战速决的意思是什么| 什么样的智齿需要拔| 代茶饮是什么意思| 额头长痘痘是什么原因| 没有精液是什么原因| 节肢动物用什么呼吸| 坐骨神经有什么症状| 什么是邮箱地址| 慢性宫颈炎是什么原因引起的| 阴茎里面痒是什么原因| 乙酉是什么意思| 流鼻血是什么原因引起的| 想入非非什么意思| 身经百战是什么意思| 酪氨酸酶是什么东西| 倾字五行属什么| 射频消融术是什么手术| 貔貅和麒麟有什么区别| 黑眼圈是什么原因导致的| mw是什么单位| 什么是指标到校| 白芍的功效与作用是什么| 爸爸的哥哥的老婆叫什么| 能是什么意思| 滴虫性阴道炎用什么药好| 北海特产有什么值得带| 浅表性胃炎伴糜烂吃什么药效果好| 中医考证需要什么条件| 什么是纳氏囊肿| 儿童上火了吃什么降火最快| 羊水是什么颜色的| 为什么要延迟退休| 割韭菜是什么意思| 小螃蟹吃什么| 舌头开裂吃什么药| 医学mr是什么意思| 十月30号是什么星座| 嘿咻是什么意思| 未见明显血流信号是什么意思| 2月9日什么星座| 小腿麻木是什么原因| 梦见假牙掉了是什么意思| 白陶土样便见于什么病| 淀粉可以用什么代替| 着痹是什么意思| 奇花异草的异什么意思| 可喜可贺是什么意思| 老年人流鼻血是什么原因| 牙龈出血用什么药| 什么鸡没有翅膀| 颈椎病最怕干什么活| 尿频尿急是什么症状| 肚子为什么会胀气| 蓝色妖姬的花语是什么| 百度
blob: f056d5e3fdcec3466e9d7b0f2e3c0076f5c20d32 [file] [log] [blame]
# Copyright 2020 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
This script runs Chrome and automatically navigates through the given list of
URLs the specified number of times.
Usage: vpython3 auto-nav.py <chrome dir> <number of navigations> <url> <url> ...
Optional flags:
* --interval <seconds>, -i <seconds>: specify a number of seconds to wait
between navigations, e.g., -i=5
* --start_prompt, -s: start Chrome, then wait for the user to press Enter before
starting auto-navigation
* --exit-prompt, -e: after auto-navigation, wait for the user to press Enter
before shutting down chrome.exe
* --idlewakeups_dir: Windows only; specify the directory containing
idlewakeups.exe to print measurements taken by IdleWakeups,
e.g., --idlewakeups_dir=tools/win/IdleWakeups/x64/Debug
Optional flags to chrome.exe, example:
-- --user-data-dir=temp --disable-features=SomeFeature
Note: must be at end of command, following options terminator "--". The options
terminator stops command-line options from being interpreted as options for this
script, which would cause an unrecognized-argument error.
"""
# [VPYTHON:BEGIN]
# python_version: "3.8"
# wheel: <
# name: "infra/python/wheels/selenium-py2_py3"
# version: "version:3.14.0"
# >
# wheel: <
# name: "infra/python/wheels/urllib3-py2_py3"
# version: "version:1.24.3"
# >
# wheel: <
# name: "infra/python/wheels/psutil/${vpython_platform}"
# version: "version:5.7.2"
# >
# [VPYTHON:END]
import argparse
import os
import subprocess
import sys
import time
import urllib
try:
import psutil
from selenium import webdriver
except ImportError:
print('Error importing required modules. Run with vpython3 instead of '
'python.')
sys.exit(1)
DEFAULT_INTERVAL = 1
EXIT_CODE_ERROR = 1
# Splits list |positional_args| into two lists: |urls| and |chrome_args|, where
# arguments starting with '-' are treated as chrome args, and the rest as URLs.
def ParsePositionalArgs(positional_args):
urls, chrome_args = [], []
for arg in positional_args:
if arg.startswith('-'):
chrome_args.append(arg)
else:
urls.append(arg)
return [urls, chrome_args]
# Returns an object containing the arguments parsed from this script's command
# line.
def ParseArgs():
# Customize usage and help to include options to be passed to chrome.exe.
usage_text = '''%(prog)s [-h] [--interval INTERVAL] [--start_prompt]
[--exit_prompt] [--idlewakeups_dir IDLEWAKEUPS_DIR]
chrome_dir num_navigations url [url ...]
[-- --chrome_option ...]'''
additional_help_text = '''optional arguments to chrome.exe, example:
-- --enable-features=MyFeature --browser-startup-dialog
Must be at end of command, following the options
terminator "--"'''
parser = argparse.ArgumentParser(
epilog=additional_help_text,
usage=usage_text,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument(
'chrome_dir', help='Directory containing chrome.exe and chromedriver.exe')
parser.add_argument('num_navigations',
type=int,
help='Number of times to navigate through list of URLs')
parser.add_argument('--interval',
'-i',
type=int,
help='Seconds to wait between navigations; default is 1')
parser.add_argument('--start_prompt',
'-s',
action='store_true',
help='Wait for confirmation before starting navigation')
parser.add_argument('--exit_prompt',
'-e',
action='store_true',
help='Wait for confirmation before exiting chrome.exe')
parser.add_argument(
'--idlewakeups_dir',
help='Windows only; directory containing idlewakeups.exe, if using')
parser.add_argument(
'url',
nargs='+',
help='URL(s) to navigate, separated by spaces; must include scheme, '
'e.g., "http://"')
args = parser.parse_args()
args.url, chrome_args = ParsePositionalArgs(args.url)
if not args.url:
parser.print_usage()
print(os.path.basename(__file__) + ': error: missing URL argument')
exit(EXIT_CODE_ERROR)
for url in args.url:
if not urllib.parse.urlparse(url).scheme:
print(os.path.basename(__file__) +
': error: URL is missing required scheme (e.g., "http://"): ' + url)
exit(EXIT_CODE_ERROR)
return [args, chrome_args]
# If |path| does not exist, prints a generic error plus optional |error_message|
# and exits.
def ExitIfNotFound(path, error_message=None):
if not os.path.exists(path):
print('File not found: {}.'.format(path))
if error_message:
print(error_message)
exit(EXIT_CODE_ERROR)
def main():
# Parse arguments and check that file paths received are valid.
args, chrome_args = ParseArgs()
ExitIfNotFound(os.path.join(args.chrome_dir, 'chrome.exe'),
'Build target "chrome" to generate it first.')
chromedriver_exe = os.path.join(args.chrome_dir, 'chromedriver.exe')
ExitIfNotFound(chromedriver_exe,
'Build target "chromedriver" to generate it first.')
if args.idlewakeups_dir:
idlewakeups_exe = os.path.join(args.idlewakeups_dir, 'idlewakeups.exe')
ExitIfNotFound(idlewakeups_exe)
# Start chrome.exe. Disable chrome.exe's extensive logging to make reading
# this script's output easier.
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
for arg in chrome_args:
chrome_options.add_argument(arg)
driver = webdriver.Chrome(os.path.abspath(chromedriver_exe),
options=chrome_options)
if args.start_prompt:
driver.get(args.url[0])
input('Press Enter to begin navigation...')
# Start IdleWakeups, if using, passing the browser process's ID as its target.
# IdleWakeups will monitor the browser process and its children. Other running
# chrome.exe processes (i.e., those not launched by this script) are excluded.
if args.idlewakeups_dir:
launched_processes = psutil.Process(
driver.service.process.pid).children(recursive=False)
if not launched_processes:
print('Error getting browser process ID for IdleWakeups.')
exit()
# Assume the first child process created by |driver| is the browser process.
idlewakeups = subprocess.Popen([
idlewakeups_exe,
str(launched_processes[0].pid), '--stop-on-exit', '--tabbed'
],
stdout=subprocess.PIPE)
# Navigate through |args.url| list |args.num_navigations| times, then close
# chrome.exe.
interval = args.interval if args.interval else DEFAULT_INTERVAL
for _ in range(args.num_navigations):
for url in args.url:
driver.get(url)
time.sleep(interval)
if args.exit_prompt:
input('Press Enter to exit...')
driver.quit()
# Print IdleWakeups' output, if using.
if args.idlewakeups_dir:
print(idlewakeups.communicate()[0])
if __name__ == '__main__':
sys.exit(main())
本科是什么学历 密度增高影是什么意思 饭后呕吐是什么原因引起的 小便少是什么原因 姑奶奶的老公叫什么
anti什么意思 鲨鱼用什么呼吸 免疫力和抵抗力有什么区别 什么是海藻糖 wear是什么意思
脚气是什么菌引起的 照见五蕴皆空什么意思 膝关节痛挂什么科 吃什么能排湿气 什么人不能吃黄芪
肛门下坠感是什么原因 肝fnh是什么病 回头是岸是什么生肖 带状疱疹是什么 学生近视配什么镜片好
梅毒是什么huizhijixie.com 发财树是什么树hcv9jop7ns2r.cn 爱思是什么hcv8jop9ns8r.cn 为什么打哈欠hcv8jop3ns4r.cn 脸上反复长痘是什么原因hcv8jop7ns5r.cn
地中海贫血有什么症状zhiyanzhang.com 呃呃是什么意思hcv9jop6ns0r.cn 宫腔内异常回声是什么意思hcv7jop6ns3r.cn 吃瓜群众是什么意思hcv9jop5ns2r.cn 什么辣椒最辣hcv7jop6ns8r.cn
a型血的人容易得什么病hcv9jop0ns2r.cn 赖氨酸是什么hcv9jop1ns5r.cn 均匀是什么意思hcv8jop3ns6r.cn 什么的海藻dayuxmw.com 散佚是什么意思hcv8jop3ns7r.cn
大便失禁是什么原因造成的imcecn.com ca199是什么意思hcv7jop6ns7r.cn 外痔是什么样子的hcv9jop5ns2r.cn 脑溢血有什么症状hcv7jop9ns3r.cn 容易紧张是什么原因hcv9jop6ns5r.cn
百度