Mechanicalsoup Proxy in python

0

Regarding requests in Python using mechanicalsoup, how do I open the site using a proxy.

import mechanicalsoup

br = mechanicalsoup.StatefulBrowser()

site = 'www.exemplo.com.br'

open = br.open(site)

resp = open.text

print(resp)
    
asked by anonymous 30.04.2018 / 07:54

1 answer

0

Through session.proxies :

import mechanicalsoup

br = mechanicalsoup.StatefulBrowser()
site = 'www.exemplo.com.br'

proxies = {
    'https': 'my.https.proxy:8080',
    'http':  'my.http.proxy:8080'
}
br.session.proxies = proxies

open = br.open(site)
resp = open.text
print(resp)
    
30.04.2018 / 23:10