简体   繁体   中英

Python: how to use lots of proxies in module REQUESTS

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?

定义list_of_proxies = [{proxy_0}, {proxy_1}, ...] ,然后根据需要将它们粘贴r = requests.get(url, headers=headers, proxies = list_of_proxies[i]) list_of_proxies = [{proxy_0}, {proxy_1}, ...] r = requests.get(url, headers=headers, proxies = list_of_proxies[i]) ,根据其中的逻辑设置i您的代码。

Define list of proxies and then use random.choice(list) function to call random choice from list and use in your code.

Thank you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM