API-简单的Web搜索引擎。目的是为无限的URL列表(网页)索引,然后能够快速搜索相关的URL来针对查询。该引擎使用Elasticsearch数据库。
新URL的索引操作首先爬网,然后从页面中提取标题和主要文本内容。然后,一个代表URL数据的新文档保存在Elasticsearch中,并用于索引。
在搜索相关URL时,引擎将将查询与每个文档的数据(网页)的数据进行比较,并检索符合查询的URL列表,并按相关性排序。
该搜索引擎可以与UI一起使用:https://github.com/anthonysigogne/web-search-engine-ui
此API适用于有限的语言列表,请参阅此处以获取完整列表:https://www.elastic.co/guide/en/elasticsearch/reference/current/current/analysis-lang-lang-analyzer.html。
可以在此处找到演示:http://searchengine.byprog.com/
新闻网络的大约500个法国URL和500英文URL http://www.france24.com/已被索引。
此工具需要Python3+和Elasticsearch5+ 。
git clone https://github.com/AnthonySigogne/web-search-engine.git
cd web-search-engine
pip install -r requirements.txt
然后,运行该工具:
FLASK_APP=index.py HOST=<ip> PORT=<port> USERNAME=<username> PASSWORD=<password> flask run
在哪里 :
ip + port :通往Elasticsearch的路线username + password :访问的凭据要在调试模式下运行,请在命令中perdent FLASK_DEBUG=1 :
FLASK_DEBUG=1 ... flask run
要使用Docker运行该工具,您可以使用我的Dockerhub图像:https://hub.docker.com/r/anthonysigogne/web-search-engine/
docker run -p 5000:5000
-e "HOST=<ip>"
-e "PORT=<port>"
-e "USERNAME=<username>"
-e "PASSWORD=<password>"
anthonysigogne/web-search-engine
在哪里 :
ip + port :通往Elasticsearch的路线username + password :凭证访问Elasticsearch或者,构建自己的码头图像:
git clone https://github.com/AnthonySigogne/web-search-engine.git
cd web-search-engine
docker build -t web-search-engine .
要列出API的所有服务,请在Web浏览器中输入此端点:http:// localhost:5000/
通过其URL索引网页。
URL
/指数
方法
POST
形成数据参数
必需的:
url=[string] ,索引的URL
成功响应
Success错误响应
样品呼叫(卷发)
curl http://localhost:5000/index --data "language=en&url=https://www.byprog.com/en/"
查询引擎以找到相关URL的列表。在JSON中返回按相关性和匹配URL的总数排序的匹配URL的sublist。
URL
/搜索
方法
POST
形成数据参数
必需的:
query=[string] ,搜索查询
不需要:
start=[integer] ,命中的开始(默认为0)
hits=[integer] ,查询返回的命中次数(默认为10)
highlight=[integer] ,返回每个URL的突出显示零件(默认情况下为0或1,0)
成功响应
{
"total": 1,
"results": [
{
"title": "Anthony Sigogne / Freelance / Full-Stack Developer",
"description": "Full-Stack Developer specialized in new technologies and innovative IT solutions.",
"url": "https://www.byprog.com/en/"
}
]
}
错误响应
样品呼叫(卷发)
curl http://localhost:5000/search --data "query=freelance fullstack"
麻省理工学院