Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active February 3, 2017 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/6f8b8f9bf7deac7e850af253a91c3d8f to your computer and use it in GitHub Desktop.
Save kurozumi/6f8b8f9bf7deac7e850af253a91c3d8f to your computer and use it in GitHub Desktop.
【Python】SOCKS5プロキシを利用してWEBページにアクセスする方法
# coding: utf-8
import socks
import socket
import urllib.request
try:
socks.set_default_proxy(socks.SOCKS5, "localhost", 1080)
socket.socket = socks.socksocket
url = "http://a-zumi.net"
request = urllib.request.Request(url)
with urllib.request.urlopen(request) as page:
print(page.read())
except Exception as e:
print("Error:{}".format(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment