M
M
Max Payne2016-06-02 21:44:46
Python
Max Payne, 2016-06-02 21:44:46

How to implement proper proxy work in requests python?

I use requests to send http requests. The problem is this - the documentation for requests states that the proxy must be set in the following form:

proxies = {
  'http': 'http://10.10.1.10:3128',
  'https': 'http://10.10.1.10:1080',
}

requests.get('http://example.org', proxies=proxies)

I send a request to https (there is a redirect to https if I request the same page via http) page, however, not all proxies can work with https and I get an error if I specify in the code like this, when the proxy is not https:
requests.get('http://example.org', proxies={ 'https': 'http://10.10.1.10:1080' } )

But if you always specify http, then as a result the program does not return the value I need.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max Payne, 2017-11-21
@YardalGedal

requests Advanced Usage

import requests

proxies = {
  'http': 'http://10.10.1.10:3128',
  'https': 'http://10.10.1.10:1080',
}

requests.get('http://example.org', proxies=proxies)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question