如何解决使用 BS4 和请求通过代理解析 RSS 提要时出错
我尝试使用 BeautifulSoup 获取 RSS 提要内容。当我解析 https://habrahabr.ru/users/gordejvv/rss/posts/ 时,everythink 工作正常,但一些 rss 提要上升错误:
requests.exceptions.ProxyError: HTTPConnectionPool(host='94.181.48.110',port=1256): Max retries exceeded with url: http://www.allcio.ru/cionews/security/?rss=Y (Caused by ProxyError('Cannot connect to proxy.',NewConnectionError( “
我也尝试用 feedparser 来做,但错误仍然存在 我的代码:
import requests
from bs4 import BeautifulSoup
URLS = [
'http://www.allcio.ru/cionews/security/?rss=Y','https://habrahabr.ru/users/gordejvv/rss/posts/'
]
PROXIES = {
'http': 'http://94.181.48.110:1256'
}
def main1():
for url in URLS:
soup = BeautifulSoup(requests.get(url,proxies=PROXIES).content,"lxml")
print(url)
print(len(soup))
if __name__ == '__main__':
main1()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。