Categorygithub.com/lichao-mobanche/go-extractor-server

# README

go-extractor-server

该项目提供提链服务,使用http+json与外界交互,灵活配置工作线程数量,使用简单方便。

基本使用

编译

make build

运行

extractor-server run -c examples/extractor-server.yaml

配置

建议将工作线程数配置为 cpu核数-1

参数含义类型是否必需
worker.number工作线程数int默认工作线程数为4
queue.number队列中缓存请求数量int默认为4000,请求数量过多会返回429错误码
http.addr地址和端口string默认端口7890

基础功能

  • 正则提链
  • css提链
  • xpath提链
  • 只提取本站
  • 自动去除锚点
  • 提链黑白名单(domain, pattern)
  • 支持xml、html格式文本
  • 适配多种编码方式
  • 默认提取html、htm、无后缀 链接

请求格式

http+json

参数含义类型是否必需
URL请求urlstringY
ContentTypehttp header中的ContentTypestringY
Content需要提链的页面string,使用base64编码Y
OnlyHomeSite是否只提取本站bool(false)N
IfRegexp是否使用正则提链bool(false)N
CSSSelectorscss提链规则string[]N
XPathQuerysxpath提链规则string[]N
AllowedDomainsdomain白名单string[]N
DisallowedDomainsdomain黑名单string[]N
AllowedURLFilterspattern黑名单string[]N
DisallowedURLFilterspattern黑名单string[]N
AllowedExts被允许的后缀string[]N

返回格式

参数含义类型
re正则提链结果string[]
xpathxpath提链结果string[]
csscss提链结果string[]

性能(非正则提链)

非正则提链快于正则提链

测试页面 https://www.sohu.com/ 单请求平均耗时与客户端数量/工作线程数成正相关

客户端数量/请求总量工作线程数qps单请求平均耗时
100/100001123.23350.8072 secs
100/100004316.28940.3145 secs

未来方向

  • 抽取器

License

MIT licensed.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author