Opener = urllib2.build_opener(keepalive_handler)Įxcept: traceback.print_exc(file=sys.stdout)ĭef loadUrl(url, profiler, enable_proxy = False): Opener = urllib2.build_opener(cookie_handler, urllib2.HTTPBasicAuthHandler(), urllib2.HTTPHandler())
#Urllib2 python 3 install mac os#
Req.add_header('User-Agent','Mozilla/5.0 (iPhone CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53')Ĭookie_handler = urllib2.HTTPCookieProcessor(Cookie_Jar) Req.add_header('Sec-WebSocket-Extensions', 'permessage-deflate client_max_window_bits, x-webkit-deflate-frame') Req.add_header('Sec-WebSocket-Version', '13') Req.add_header('Cache-Control','no-cache') Req.add_header('Sec-WebSocket-Key', str_guid) tomation_url = server_url + 'site/automation/'ĭef send_web_socket(Cookie_Jar,url_to_call): Self.streaming_opener = urllib2.build_opener(cookie_processor, Self.opener = urllib2.build_opener(cookie_processor, proxy_handler)
Proxy_handler = get_proxy_handler(proxies, Self._update_auth(password=password, token=token)Ĭookie_processor = urllib2.HTTPCookieProcessor( # TODO: actually use the repository info in the requests Self.upload_tmp_dir = (upload_tmp_dir if upload_tmp_dir is not None Self.ignored_suffixes = DEFAULT_IGNORED_SUFFIXES Self.ignored_prefixes = DEFAULT_IGNORED_PREFIXES Timeout=20, blob_timeout=None, cookie_jar=None, Ignored_prefixes=None, ignored_suffixes=None, Password=None, token=None, repository="default", Session.Def _init_(self, server_url, user_id, device_id, client_version, # Tor uses the 9050 port as the default socks port
#Urllib2 python 3 install install#
Установка - pip install requests requests Print("Used " + str(counter) + " IPs and got " + str(err) + " errors") #wait till next identity will be available Phantomjs_path = '/your/path/to/phantomjs' С Selenium + PhantomJS: from selenium import webdriver С urllib (имя urllib2 в Python 3): import socks # allow some time for IP address to refresh
# set new ip and check ip before scraping for each new url Print('current ip address :', response.read()) With om_port(port=9151) as controller:Ĭonn = ("") # disable socks server and enabling again Sproc = subprocess.Popen(r'./Tor Browser/Browser/firefox.exe') # start Tor (wait 30 sec for Tor to load) Tor -service install -options ControlPort 9151