如何在python 3中使用带有代理的feedparser? [英] How to use feedparser with proxy in python 3?

查看:78
本文介绍了如何在python 3中使用带有代理的feedparser?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用代理和 feedparser.这就是我在 urllib2 中的做法:

I'd like to use a proxy and feedparser. This is how I'd do in urllib2:

import urllib2, feedparser
proxy = urllib2.ProxyHandler({"http":"proxy:port"})
d = feedparser.parse('http://www.shop.inonit.in/RSSFeedDetails.aspx?PID=801', handlers = [proxy])

如何使用 urllib3 来实现?

How do I do it with urllib3?

推荐答案

import feedparser
from urllib.request import ProxyHandler, build_opener
proxy_handler = ProxyHandler(proxies)
print(feedparser.parse("rss_url", handlers=[proxy_handler]))

同样,我们可以为提要解析器提供代理处理程序.

Similarly, we can provide a proxy handler for feed parser.

这篇关于如何在python 3中使用带有代理的feedparser?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆