python - HTTPS proxies does not work when sending requests
问题描述
I want to crawl some websites with Python and BeautifulSoup lib, and I want to set some proxies. I came a cross a problem with setting up the proxies. When ever I set https proxy, it does not work, but when i set the http proxy it works. Do you know whats the problem?
import requests
https_proxies = [{'https': 'https://60.191.11.241:3128'},
{'https': 'https://129.226.162.177:80'},
{'https': 'https://103.231.80.202:55443'},
{'https': 'https://167.172.171.115:34538'},
{'https': 'https://103.104.193.34:6000'},
{'https': 'https://200.60.4.238:999'}]
for proxy in https_proxies:
try:
r1 = requests.get("https://edition.cnn.com/", proxies=proxy, timeout = 3)
print(r1)
except:
print("BAD PROXY")
http_proxies = [{'http': 'http://194.169.164.14:34334'},
{'http': 'http://46.167.238.109:5678'},
{'http': 'http://201.59.102.35:5678'},
{'http': 'http://31.25.243.40:9147'},
{'http': 'http://178.162.202.44:1025'}]
for proxy in http_proxies:
try:
r1 = requests.get("https://edition.cnn.com/", proxies=proxy, timeout = 3)
print(r1)
except:
print("BAD PROXY")
I have tried with more than 50 HTTPS proxies on 10 different websites, and its always the same. This is the website I have used for getting the proxies: https://geonode.com/free-proxy-list And this: https://free-proxy-list.net/
解决方案
推荐阅读
- ldap - 如何使用关系 DBMS 作为 Shibboleth IDP 而不是默认 LDAP 的身份验证提供程序?
- python - 如果我设置 as_index = False,为什么带有聚合函数的 groupby 不返回分组列?
- c - 释放分配给 C 中图形的内存时的堆损坏警报
- python - 我用代理发送请求对吗?
- python - Python 日期时间函数 - 从 Pandas 迁移到 Dask
- python - 尝试在 CMD 中为 python 使用 PIP 并获取“'pip' 未被识别为内部或外部命令、可运行程序或批处理文件。”
- r - GAMM在绘制图表时过度夸大了一个因子水平?
- json - 如何保护我的“key.json”文件在 Github 上不被更新?
- javascript - 使用 Javascript 将 CSV 转换为 HTML 表。使用 CSV 中的列添加 CSS 类
- sql - 创建数据库 - Pizza 场景