A Simple Guide to Python Use Shadowsocks to Open Blocked URL – Python Web Crawler Tutorial

By | August 28, 2019

Shadowsocks is a powerful vpn application, it can allow us to access some blocked website. In this tutorial, we will introduce how to use shadowsocks to access blocked websites using python.

shadowsocks tutorials and examples

Preliminaries

You should install shadowsocks and can access blocked website by your browser.

Set shadowsocks proxy

Shadowsocks use 127.0.0.1:1080 to a proxy defautly, if you change it. You should use your new ip:port proxy.

proxies = {'https': 'https://127.0.0.1:1080', 'http': 'http://127.0.0.1:1080'}

Create a proxy handler

proxies_processor = urllib.request.ProxyHandler(proxies)

Ignore ssl verification

Best Practice to OpenerDirector Ignore SSL Verification in Python 3.x – Python Web Crawler Tutorial

Create a OpenerDirector object with proxy handler and ssl handler

opener = urllib.request.build_opener(proxies_processor, sslHandler)

Add http request headers for opener

Best Practice to Python OpenDirector Add HTTP Request Header – Python Web Crawler Tutorial

Get content from http response

A Simple Guide to Get String Content from HTTP Response Header – Python Web Crawler Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *