twisted http client

妖精的绣舞 提交于 2019-12-03 02:10:40

As of Twisted 9.0, there are actually two HTTP clients available. The older one has quite a few features, such as automatically following redirects, interpreting cookie headers, etc. You can find an example of its usage here:

http://twistedmatrix.com/documents/current/web/examples/

(getpage.py and dlpage.py)

Unfortunately, the interface presented by the older client makes a number of common tasks difficult. For example, using getPage, you cannot examine arbitrary response headers.

The newer HTTP client isn't yet as featureful as the old one, but it presents an interface intended to eliminate the limitations of getPage. It is also intended to be more easily extended and customized. You can find a document describing its usage here:

http://twistedmatrix.com/documents/current/web/howto/client.html

I started using treq with twisted. treq has an API which is very similar to Requests. https://pypi.python.org/pypi/treq/0.2.0

As of Twisted 10, you may want to use the Agent class.

Please follow this link: http://twistedmatrix.com/documents/10.2.0/web/howto/client.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!