Yuzayu one of the ways to get data from this site:
import mechanize br = mechanize.Browser() br.open("http://www.example.com/") well or requests if cookies are not needed. Is it possible to do the same using any type of proxy 111.111.111.111:8080?
Yuzayu one of the ways to get data from this site:
import mechanize br = mechanize.Browser() br.open("http://www.example.com/") well or requests if cookies are not needed. Is it possible to do the same using any type of proxy 111.111.111.111:8080?
The mechanize browser (works in Python 2) has a method for setting a proxy - set_proxies :
#!/usr/bin/env python2 import mechanize br = mechanize.Browser() proxies = { "http": "111.111.111.111:8080", "ftp": "proxy.example.com", } br.set_proxies(proxies) br.open("http://www.example.com/") There are helpful examples on the docks.
Through a proxy, you can also go to requests (works in Python 2 and 3):
#!/usr/bin/env python import requests proxies = { 'http': '10.10.1.10:3128', 'https': '10.10.1.10:1080', } requests.get('http://example.org', proxies=proxies) SOCKS proxies are also supported. Details in the documentation .
And yes, requests course can work with cookie . RTFM, as they say!
requests - a library for all occasions. Updated the answer. - zed#! line) . For example, #!/usr/bin/env python2 for the first example and #!/usr/bin/env python for the second (the second example both on Python 2 and 3 should work). - jfsSource: https://ru.stackoverflow.com/questions/615970/
All Articles