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"
麻省理工學院