From 0f24456f167e9149c33ffcef52509703dadd0709 Mon Sep 17 00:00:00 2001 From: jyhl Date: Wed, 29 Apr 2020 16:26:16 +0800 Subject: [PATCH] add sleep --- demo.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/demo.py b/demo.py index 7114a10..f128f9b 100644 --- a/demo.py +++ b/demo.py @@ -1,13 +1,14 @@ +#!coding: utf-8 + import os import zipfile from selenium import webdriver PROXY_HOST = 'u1.5.tn.16yun.cn' # rotating proxy or host -PROXY_PORT = 6441 # port -PROXY_USER = '16ZJZYVL' # username -PROXY_PASS = '167813' # password - +PROXY_PORT = 6441 # port +PROXY_USER = '16ZJZYVL' # username +PROXY_PASS = '112213' # password manifest_json = """ { @@ -72,7 +73,7 @@ def get_chromedriver(use_proxy=False, user_agent=None): # 如报错 chrome-extensions # chrome_options.add_argument("--disable-extensions") - # 防止被反爬 关闭webdriver flag + # 防止被反爬 关闭 webdriver flag # chrome_options.add_experimental_option('excludeSwitches', ['enable-automation']) if use_proxy: @@ -89,10 +90,13 @@ def get_chromedriver(use_proxy=False, user_agent=None): chrome_options=chrome_options) return driver + def main(): + import time driver = get_chromedriver(use_proxy=True) - #driver.get('https://www.google.com/search?q=my+ip+address') + driver.implicitly_wait(10) # seconds driver.get('https://httpbin.org/ip') + time.sleep(10) if __name__ == '__main__': main()