@@ -90,24 +90,13 @@ def make_executable(file_path):
9090 os .chmod (file_path , mode )
9191
9292
93- def requests_get (url ):
94- response = None
95- try :
96- response = requests .get (url )
97- except Exception :
98- # Prevent SSLCertVerificationError / CERTIFICATE_VERIFY_FAILED
99- url = url .replace ("https://" , "http://" )
100- response = requests .get (url )
101- return response
102-
103-
104- def requests_get_with_retry (url ):
93+ def get_proxy_info ():
10594 use_proxy = None
10695 protocol = "http"
96+ proxy_string = None
10797 user_and_pass = None
10898 if " --proxy=" in " " .join (sys .argv ):
10999 from seleniumbase .core import proxy_helper
110-
111100 for arg in sys .argv :
112101 if arg .startswith ("--proxy=" ):
113102 proxy_string = arg .split ("--proxy=" )[1 ]
@@ -133,30 +122,41 @@ def requests_get_with_retry(url):
133122 proxy_string = "%s@%s" % (user_and_pass , proxy_string )
134123 use_proxy = True
135124 break
125+ return (use_proxy , protocol , proxy_string )
126+
127+
128+ def requests_get (url ):
129+ use_proxy , protocol , proxy_string = get_proxy_info ()
130+ proxies = None
136131 response = None
137132 if use_proxy :
138133 proxies = {protocol : proxy_string }
134+ try :
135+ response = requests .get (url , proxies = proxies , timeout = 3 )
136+ except Exception :
137+ # Prevent SSLCertVerificationError / CERTIFICATE_VERIFY_FAILED
138+ url = url .replace ("https://" , "http://" )
139+ time .sleep (0.04 )
140+ response = requests .get (url , proxies = proxies , timeout = 4 )
141+ return response
142+
143+
144+ def requests_get_with_retry (url ):
145+ use_proxy , protocol , proxy_string = get_proxy_info ()
146+ proxies = None
147+ response = None
148+ if use_proxy :
149+ proxies = {protocol : proxy_string }
150+ try :
151+ response = requests .get (url , proxies = proxies , timeout = 3 )
152+ except Exception :
153+ time .sleep (1 )
139154 try :
140- response = requests .get (url , proxies = proxies )
141- except Exception :
142- time .sleep (1.1 )
143- try :
144- response = requests .get (url , proxies = proxies )
145- except Exception :
146- time .sleep (1.2 )
147- response = requests .get (url , proxies = proxies )
148- return response
149- else :
150- try :
151- response = requests .get (url )
155+ response = requests .get (url , proxies = proxies , timeout = 4 )
152156 except Exception :
153- time .sleep (1.1 )
154- try :
155- response = requests .get (url )
156- except Exception :
157- time .sleep (1.2 )
158- response = requests .get (url )
159- return response
157+ time .sleep (1 )
158+ response = requests .get (url , proxies = proxies , timeout = 4 )
159+ return response
160160
161161
162162def main (override = None , intel_for_uc = None ):
0 commit comments