python requests with proxy code example

Example 1: python requests get proxy

import requests

proxies = { "http": "http://10.10.10.10:8000",
           "https": "https://10.10.10.10:8000"
}
r = requests.get("http://toscrape.com", proxies=proxies)

Example 2: python proxy scraper

import proxyscrape

collector = proxyscrape.create_collector('default', 'http')  # Create a collector for http resources
proxy = collector.get_proxy({'country': 'united states'})  # Retrieve a united states proxy

Example 3: post request with proxy python

from proxy_requests import ProxyRequests

r = ProxyRequests('url here')
r.set_headers({'name': 'rootVIII', 'secret_message': '7Yufs9KIfj33d'})
r.post_with_headers({'key1': 'value1', 'key2': 'value2'})

Tags:

Misc Example