http库测试工具 - httpbin
http
(图片来自互联网)
如果一个人想学习爬虫技术,我会首先推荐他学会使用httpbin!
httpbin(官网|github)是一个很不错测试工具,你可以放心大胆的黑他,而不用担心他报复你。他有点像一个蜜罐,时刻等待着你的光临,然后根据你的请求,给你返回你想要的东西
相同推荐
类似这种能够很方便调试接口的还有很多,但是无疑还是httpbin最好用。
requestb
putsreq
ttpresponder
runscope
如何使用
使用你擅长的语言,与它的接口互动。
接口
接口列表
Endpoint | Description |
/ | This page. |
/ip | Returns Origin IP. |
/user-agent | Returns user-agent. |
/headers | Returns header dict. |
/get | Returns GET data. |
/post | Returns POST data. |
/patch | Returns PATCH data. |
/put | Returns PUT data. |
/delete | Returns DELETE data |
/gzip | Returns gzip-encoded data. |
/deflate | Returns deflate-encoded data. |
/status/:code | Returns given HTTP Status code. |
/response-headers | Returns given response headers. |
/redirect/:n | 302 Redirects n times. |
/redirect-to?url=foo | 302 Redirects to the foo URL. |
/relative-redirect/:n | 302 Relative redirects n times. |
/cookies | Returns cookie data. |
/cookies/set?name=value | Sets one or more simple cookies. |
/cookies/delete?name | Deletes one or more simple cookies. |
/basic-auth/:user/:passwd | Challenges HTTPBasic Auth. |
/hidden-basic-auth/:user/:passwd | 404'd BasicAuth. |
/digest-auth/:qop/:user/:passwd | Challenges HTTP Digest Auth. |
/stream/:n | Streams n – 100 lines. |
/delay/:n | Delays responding for n – 10 seconds. |
/drip | Drips data over a duration after an optional initial delay, then (optionally) returns with the given status code. |
/range/:n | Streams n bytes, and allows specifying a Range header to select a subset of the data. Accepts a chunk_size and request duration parameter. |
/html | Renders an HTML Page. |
/robots.txt | Returns some robots.txt rules. |
/deny | Denied by robots.txt file. |
/cache | Returns 200 unless an If-Modified-Since or If-None-Match header is provided, when it returns a 304. |
/cache/:n | Sets a Cache-Control header for n seconds. |
/bytes/:n | Generates n random bytes of binary data, accepts optional seed integer parameter. |
/stream-bytes/:n | Streams n random bytes of binary data, accepts optional seed and chunk_size integer parameters. |
/links/:n | Returns page containing n HTML links. |
/forms/post | HTML form that submits to /post |
/xml | Returns some XML |
/encoding/utf8 | Returns page containing UTF-8 data. |
[...]后端将示例接口返回数据写在文件里,接口直接返回静态文件数据。此种方式,由后端定义接口数据格式。另外,有一个开源的工具: httpbin可以用来提供接口返回指定格式的数据,中文介绍可见:https://blog.phpgao.com/how-to-httpbin.html。[...]
如果一个人像(想吧)学习爬虫
好眼力!已更正