Scraply
Scraply,是一个非常简单的HTML刮削工具,如果你知道css和jQuery,那么你就可以使用它!,Scraply应该是简单和微小的,它可以作为一个大型系统的组件,像这样的使用案例
概述
你可以通过
cli或http在你的栈中使用scraply:
# here is the CLI usage
# extracting the title and the description from scraply github repo page
$ scraply extract \
-u "https://github.com/alash3al/scraply" \
-x title='$("title").text()' \
-x description='$("meta[name=description]").attr("content")'
# same thing but with custom user agent
$ scraply extract \
-u "https://github.com/alash3al/scraply" \
-ua "OptionalCustomUserAgent"\
-x title='$("title").text()' \
-x description='$("meta[name=description]").attr("content")'
# same thing but with asking scraply to return the response body for debugging purposes
$ scraply extract \
--return-body \
-u "https://github.com/alash3al/scraply" \
-x title='$("title").text()' \
-x description='$("meta[name=description]").attr("content")'
对于
http,我们将运行http服务器,然后使用任何http客户端与之交互:
# running the http server
# by default it listens on address ":8010" which equals to "0.0.0.0:8010"
# for more information execute `$ scraply help`
$ scraply serve
# then in another shell let's execute the following curl
$ curl http://localhost:8010/extract \
-H "Content-Type: application/json" \
-s \
-d '{"url": "https://github.com/alash3al/scraply", "extractors": {"title": "$(\"title\").text()"}, "return_body": false, "user_agent": "CustomeUserAgent"}'
对于调试,有
shell:
$ scraply shell -u https://github.com/alash3al/scraply
➜ (scraply) > $("title").text()
GitHub - alash3al/scraply: Scraply a simple dom scraper to fetch information from any html based website and convert that info to JSON APIs
➜ (scraply) > request.url
https://github.com/alash3al/scraply
➜ (scraply) > response.status_code
200
➜ (scraply) > response.url
https://github.com/alash3al/scraply
➜ (scraply) > response.body
<html>.....
下载?
你可以进入发布页面并选择最新的版本。或者你可以
$ docker run --rm -it ghcr.io/alash3al/scraply scraply help
贡献?
你当然可以贡献,怎么贡献?
- 克隆该版本
- 创建你的修复/功能分支
- 创建一个拉动请求
其他的就不说了,祝您愉快!