英語| 中文版
該項目提供了一個功能強大的Web刮擦工具,可使用FastAPI,Searxng和Browserless獲取搜索結果並將其轉換為Markdown格式。它包括使用代理進行Web刮擦和處理HTML內容轉換以有效降級的能力。現在具有用於過濾搜索結果的AI集成。替代方案包括Jina.ai,FireCrawl AI,EXA AI和2markDown,為開發人員提供各種網絡刮擦和搜索引擎解決方案。
確保您安裝了以下內容:
您可以使用Docker簡化設置過程。請按照以下步驟:
克隆存儲庫:
git clone https://github.com/essamamdani/search-result-scraper-markdown.git
cd search-result-scraper-markdown運行Docker組成:
docker compose up --build使用此設置,如果更改.env或main.py文件,則不再需要重新啟動Docker。更改將自動重新加載。
按照以下步驟進行手動設置:
克隆存儲庫:
git clone https://github.com/essamamdani/search-result-scraper-markdown.git
cd search-result-scraper-markdown創建和激活虛擬環境:
virtualenv venv
source venv/bin/activate安裝依賴項:
pip install -r requirements.txt在根目錄中創建一個.ENV文件,其中包含以下內容:
SEARXNG_URL=http://searxng:8080
BROWSERLESS_URL=http://browserless:3000
TOKEN=your_browserless_token_here # Replace with your actual token
# PROXY_PROTOCOL=http
# PROXY_URL=your_proxy_url
# PROXY_USERNAME=your_proxy_username
# PROXY_PASSWORD=your_proxy_password
# PROXY_PORT=your_proxy_port
REQUEST_TIMEOUT=30
# AI Integration for search result filter
FILTER_SEARCH_RESULT_BY_AI=true
AI_ENGINE=groq
# GROQ
GROQ_API_KEY=yours_groq_api_key_here
GROQ_MODEL=llama3-8b-8192
# OPENAI
# OPENAI_API_KEY=your_openai_api_key_here
# OPENAI_MODEL=gpt-3.5-turbo-0125運行用於Searxng和無瀏覽器的Docker容器:
./run-services.sh啟動FastAPI應用程序:
uvicorn main:app --host 0.0.0.0 --port 8000要執行搜索查詢,請將get請求發送到根端點/使用查詢參數q (搜索查詢), num_results (結果數)和format (json中的get wets wet onsect或默認情況下)。
例子:
curl " http://localhost:8000/?q=python&num_results=5&format=json " # for JSON format
curl " http://localhost:8000/?q=python&num_results=5 " # by default Markdown要將特定URL的內容獲取並將其轉換為Markdown,請將get請求發送到/r/{url:path} endpoint。
例子:
curl " http://localhost:8000/r/https://example.com&format=json " # for JSON format
curl " http://localhost:8000/r/https://example.com " # by default Markdown要獲取圖像搜索結果,請使用查詢參數q (搜索查詢)和num_results (結果數)將GET請求發送到/images端點。
例子:
curl " http://localhost:8000/images?q=puppies&num_results=5 "要獲取視頻搜索結果,請使用查詢參數q (搜索查詢)和num_results (結果數)將get請求發送到/videos端點。
例子:
curl " http://localhost:8000/videos?q=cooking+recipes&num_results=5 " 該項目使用Geonode代理進行網絡刮擦。您可以使用我的Geonode會員鏈接開始其代理服務。
有關代碼的詳細說明,請訪問此處的文章。
該項目已根據MIT許可獲得許可。有關詳細信息,請參見許可證文件。
essa mamdani -essamamdani.com
歡迎捐款!請隨時提交拉動請求。