0

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?

Community
  • 1
  • 1
Petr Petrov
  • 4,090
  • 10
  • 31
  • 68

2 Answers2

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,889
  • 5
  • 34
  • 54
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.