I have some difficulties with module requests.
It takes argument proxies.
I saw in this question description on this module and I've understood, that it takes only one proxy from the dict.
But if one proxy is blocked?
I want to use dictionary with a lot of proxies, if one proxy is blocked, I want take another proxy, but how can I do that?
Asked
Active
Viewed 90 times
0
Community
- 1
- 1
Petr Petrov
- 3,360
- 9
- 26
- 61
-
You are going to quickly run out of proxies, you may find using selenium with PhantomJs is a better option – Padraic Cunningham Oct 20 '16 at 14:32
2 Answers
0
Define list_of_proxies = [{proxy_0}, {proxy_1}, ...] and then paste them as needed r = requests.get(url, headers=headers, proxies = list_of_proxies[i]) where you set i according to the logic of your code.
Nurjan
- 5,532
- 5
- 32
- 50
0
Define list of proxies and then use random.choice(list) function to call random choice from list and use in your code.
Thank you.
user7365756
- 11
- 3