使用 asyncore 阅读网站 [英] Reading a website with asyncore

查看:30
本文介绍了使用 asyncore 阅读网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想异步阅读一个网站,据我所知,这在 urllib 中是不可能的.现在我尝试使用普通套接字阅读,但 HTTP 给我带来了麻烦.我遇到了各种时髦的编码,例如 transfer-encoding: chunked,必须手动解析所有这些东西,而且我现在喜欢编码 C,而不是 python.

I would like to read a website asynchronously, which isnt possible with urllib as far as I know. Now I tried reading with with plain sockets, but HTTP is giving me hell. I run into all kind of funky encodings, for example transfer-encoding: chunked, have to parse all that stuff manually, and I feel like coding C, not python at the moment.

没有像 URLLib 这样更好的异步方式吗?我真的不想重新实现整个 HTTP 规范,因为之前都已经完成了.

Isnt there a nicer way like URLLib, asynchronously? I dont really feel like re-implementing the whole HTTP specification, when it's all been done before.

Twisted 目前不是一个选项.

Twisted isnt an option currently.

您好,

汤姆

推荐答案

你看过 http://asynchttp.sourceforge.net/?

"Python 异步 HTTP 客户端

"Asynchronous HTTP Client for Python

asynchttp"模块是 Python 库asynchat"模块的逻辑扩展,该模块构建在asyncore"和select"模块之上.我们的目标是在不使用阻塞套接字的情况下提供出色的httplib"模块的功能."

The 'asynchttp'' module is a logical extension of the Python library 'asynchat' module which is built on the 'asyncore' and 'select' modules. Our goal is to provide the functionality of the excellent 'httplib' module without using blocking sockets."

该项目的最后一次提交是 2001-05-29,所以它看起来已经死了.但无论如何它可能会引起人们的兴趣.

The project's last commit was 2001-05-29, so it looks dead. But it might be of interest anyway.

免责声明:我自己没有使用过.

Disclaimer: I have not used it myself.

此外,这篇博文有一些关于异步 HTTP 的信息.

Also, this blog post has some information on async HTTP.

这篇关于使用 asyncore 阅读网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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