从网页中提取rss、atom和其他提要

feed-seeker的Python项目详细描述


it斜押韵“热探索者”

Build StatusCoverage

用于从网页中查找Atom、RSS、RDF和XML源的库。在mediacloud项目中制作。对feedfinder2的一个渐进改进,它本身是基于feedfinder,由马克·皮尔格林编写,亚伦·斯沃茨维护,直到他早逝。

安装

库位于PyPI

pip install feed_seeker

快速启动

默认情况下,库使用requests来获取html并检查它,找出 可能的源URL:

fromfeed_seekerimportfind_feed_url>>>find_feed_url('https://github.com/mitmedialab/feed_seeker')'https://github.com/mitmedialab/feed_seeker/commits/master.atom'

要进行更彻底的搜索,请使用generate_feed_urls,它首先返回更可能的候选项。

fromfeed_seekerimportgenerate_feed_urls>>>forurlingenerate_feed_urls('https://xkcd.com'):...print(url)...https://xkcd.com/atom.xmlhttps://xkcd.com/rss.xml

要进行最彻底的搜索,请添加一个spider参数,对同一主机名上的url进行深度优先排序。注意,下面的调用需要将近4分钟,而find_feed_url则需要0.5秒。

>>>forurlingenerate_feed_urls('https://github.com/mitmedialab/feed_seeker',spider=1):...print(url)...https://github.com/mitmedialab/feed_seeker/commits/master.atom,https://github.com/mitmedialab/feed_seeker/commits/95cf320796c487df8b70f9c42281d8f26452cc31.atom,https://github.com/mitmedialab/feed_seeker/commits/3e93490cb91f7652325c2fe41ef29a5be4558d6a.atom,https://github.com/mitmedialab/feed_seeker/commits/659311b8853c4c4a67e3b4bc67a78461d825a064.atom,https://github.com/mitmedialab/feed_seeker/commits/a8f7b86eac2cedd9209ac5d2ddcceb293d2404c9.atom,https://github.com/index.atom,https://github.com/articles.atom,https://github.com/dfm/feedfinder2/commits/master.atom,https://github.com/blog.atom,https://github.com/blog/all.atom,https://github.com/blog/broadcasts.atom,https://github.com/ColCarroll.atom

急急忙忙?

如果您有一个很长的url列表,您可能需要用max_time

设置超时
>>>forurlin('https://httpstat.us/200?sleep=5000','https://github.com/mitmedialab/feed_seeker'):...try:...print('found feed:\t{}'.format(find_feed_url(url,max_time=3)))...exceptTimeoutError:...print('skipping {}'.format(url))skippinghttps://httpstat.us/200?sleep=5000foundfeed:https://github.com/mitmedialab/feed_seeker/commits/master.atom

feedfinder2

的差异

最大的区别是,所有函数都是作为生成器实现的,并且被惰性地评估。候选feed链接实际上是被访问和检查的,以确定它们是否是feed,这可能非常耗时。我们公开一个函数以查找最可能的feed链接,而另一个函数则以粗略的顺序从最突出到最少地生成链接。

还有一些基于我们在mediacloud的经验的启发式方法。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java构造函数SimpleCommandBus()不可见   Java字符串和返回   java不能在类中使用上下文?   使用Java为SOAP定制DataHandler   java“访问被拒绝”在编译servlet时   java嵌入Jetty,在给定时间后终止请求   java如何使用预先指定的URL限制AWS S3 bucket中对象的上传大小?   java理解Azure文件存储:未知hostException   java将对象作为参数传递是否会产生与将其存储在字段中相同级别的耦合?   https告诉java客户端代码接受自签名证书   Java中的简单*权威DNS服务器*   Java解压缩字节数组错误数据检查   当我用SpringDoc和接口描述API规范时,java Spring控制器验证似乎不起作用   在Java中使用PHash(OpenCV)   Kotlin中的java简单继承示例   java Infinispan:ISPN004016:服务器不再位于群集中(127.0.0.1:11222),正在从池中删除   2行滑动菜单安卓本机JAVA   使用日期选择器时Android Studio中的java 4错误   java在<之间删除内容!和/>