E
E
Evelion2013-11-13 15:49:11
Python
Evelion, 2013-11-13 15:49:11

Using Proxy in Python,

Good day ! There was a need to "rob" the pages of one resource. In the course of the script (in Python 2.7), it turned out that with frequent requests to resource pages, the latter begins to resist. Namely - to issue a banana to the ip address, limiting my activity. My provider provides a dynamic ip, so the problem can be solved by simply reconnecting to the network, but this is not suitable for automating the process. I tried to set delays when accessing pages - it helps, but not for long. Will using a proxy help me in this case? Up to this point, it was not necessary to work with a proxy at all.

Tried using the following code (Python 2.7):


 proxy_support = urllib2.ProxyHandler({"http://":"http://217.219.190.209:8080"})
    opener = urllib2.build_opener(proxy_support)
    urllib2.install_opener(opener) 

One of the free proxy addresses on the network is used as the proxy address.

The site is still not allowed. What am I doing wrong ? I ask you to suggest or direct me to read the necessary articles.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
peter_volkov, 2013-11-13
@Evelion

code formatting is lost.

proxy = urllib2.ProxyHandler({'http': '127.0.0.1'})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
urllib2.urlopen('http://www.google.com')

E
Evelion, 2013-11-13
@Evelion

Thank you all for the advice and links (useful)! The problem was solved .. Corrected, but I think the reason was still in the non-working addresses of the proxy servers. One thing was not clear.. To test the proxy, I turned to the site for checking the ip address, hoping to get the proxy address instead of the real one, but in the end in both cases I got the real address. Why is that ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question