Getting Started with the PySocks library

Table of contents

You can use the PySocks library to connect to your QuotaGuard Static SOCKS5 proxy as shown here.

This code sample will print out one of your two static IP addresses by sending an HTTP request to the HTTP Bin service.

import socks
from urlparse import urlparse
import os

# Extract proxy connection details from env variable
proxy = urlparse(os.environ['QUOTAGUARDSTATIC_URL'])

s = socks.socksocket()
s.set_proxy(socks.SOCKS5, proxy.hostname, 1080, True, proxy.username,proxy.password)
host = "httpbin.org"
s.connect((host, 80))

request = "GET /ip HTTP/1.1\nHost: "+host+"\nUser-Agent:Mozilla 5.0\n\n"
s.send(request)

response = s.recv(1024)
print response

Ready to Get Started?

Get in touch or create a free trial account

Back to top ↑

Copyright © 2009 - 2026 QuotaGuard. All rights reserved.