{"id":1548,"date":"2026-06-17T17:57:33","date_gmt":"2026-06-17T09:57:33","guid":{"rendered":"https:\/\/www.livetops.com\/?p=1548"},"modified":"2026-06-17T17:57:34","modified_gmt":"2026-06-17T09:57:34","slug":"%e6%90%ad%e5%bb%ba%e7%a7%81%e6%9c%89%e6%90%9c%e7%b4%a2%e4%bb%a3%e7%90%86%e6%9c%8d%e5%8a%a1%ef%bc%9aopenwebui-%e5%90%8e%e7%ab%af%e6%a8%a1%e6%8b%9f-searxng-%e6%9c%ac%e5%9c%b0%e6%90%9c%e7%b4%a2","status":"publish","type":"post","link":"https:\/\/www.livetops.com\/en\/archives\/1548","title":{"rendered":"Setting Up a Private Search Proxy Service: OpenWebUI + Backend Simulating SearXNG Local Search"},"content":{"rendered":"<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Implement a local search service using Python and Flask that is compatible with the SearXNG API and supports deep web crawling<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Background<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When building a personal AI assistant, one often encounters a problem: the knowledge in large language models has a cutoff date, so they cannot access the latest information. Although it\u2019s possible to integrate search engine APIs, commercial services are quite expensive, and the free versions have limits on the number of calls.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So I wrote a lightweight local search proxy service, which essentially takes<strong>Baidu Search<\/strong>Packaged as <strong>SearXNG-Compatible APIs<\/strong>, and at the same time add<strong>In-Depth Web Scraping<\/strong>Capabilities\u2014Not only does it return search results, but it also automatically extracts the body text of top-ranked pages, allowing the AI to read the original content directly.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Feature Overview<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Features<\/th><th>instructions<\/th><\/tr><\/thead><tbody><tr><td>Baidu Search<\/td><td>Based on <code>baidu_serp_api<\/code> Simulate a Baidu search to retrieve the title, link, and summary<\/td><\/tr><tr><td>Deep Crawling<\/td><td>Asynchronously and concurrently fetch the top N results pages, extract the body text, and append it to the summary<\/td><\/tr><tr><td>Multi-Extractor<\/td><td>Automatic downgrade using trafilatura \/ readability \/ goose3<\/td><\/tr><tr><td>Caching Mechanism<\/td><td>Search results are cached for 1 hour to reduce duplicate requests<\/td><\/tr><tr><td>Over-frequency Protection<\/td><td>Random delay + cooldown mechanism, reducing the probability of risk control<\/td><\/tr><tr><td>API Compatibility<\/td><td>The output format is consistent with SearXNG, allowing for direct integration with various AI applications.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Workflow<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>User Request \u2192 Flask Service \u2192 Baidu Search API \u2192 Retrieve Results List\n \u2193\n (Optional) Deep Crawl Top N\n \u2193\n Concurrently Extract Body Content\n \u2193\n Quality Score + Content Attachments\n \u2193\n Return SearXNG-Compatible JSON<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Getting Started Quickly<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Install dependencies<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install flask baidu-serp-api trafilatura readability-lxml aiohttp fake-useragent<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Optional installation (to improve extraction success rate):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install goose3<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. Start the service<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>python SearxBaiduService.py<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Or just double-click <code>RunSearcher.bat<\/code>(Windows).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By default, the service runs on <code>http:\/\/localhost:8888<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Example of Use<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Regular Search\ncurl \"http:\/\/localhost:8888\/search?q=\u4eba\u5de5\u667a\u80fd\u6700\u65b0\u8fdb\u5c55\"\n\n# Limit the Number of Results Returned\ncurl \"http:\/\/localhost:8888\/search?q=\u6df1\u5ea6\u5b66\u4e60&amp;count=4\"\n\n# Disable Deep Crawling\ncurl \"http:\/\/localhost:8888\/search?q=Transformer&amp;deep_crawl=false\"\n\n# Specify the number of items to fetch at a given depth\ncurl \"http:\/\/localhost:8888\/search?q=\u5927\u6a21\u578b&amp;deep_count=2\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. Return Format (SearXNG-compatible)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"query\": \"Artificial Intelligence\",\n  \"number_of_results\": 6,\n  \"results\": [\n    {\n \"title\": \"Article Title\",\n \"url\": \"https:\/\/...\" ,\n \"content\": \"Summary\\n\\n[In-depth content]\\nMain text...\",\n \"source\": \"baidu\",\n \"engine\": \"baidu\"\n    }\n  ]\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Optimizing Key Parameters<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In the \"Adjustable Parameters\" section at the beginning of the code, you can adjust the following parameters:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Parameters<\/th><th>default value<\/th><th>instructions<\/th><\/tr><\/thead><tbody><tr><td><code>DEFAULT_RESULT_COUNT<\/code><\/td><td>6<\/td><td>Default number of results returned<\/td><\/tr><tr><td><code>DEEP_CRAWL_MAX_RESULTS<\/code><\/td><td>6<\/td><td>Maximum number of items to crawl at maximum depth<\/td><\/tr><tr><td><code>DEEP_CRAWL_CONCURRENT<\/code><\/td><td>2<\/td><td>Number of concurrent scrapes (recommended: \u22643)<\/td><\/tr><tr><td><code>DEEP_CRAWL_TIMEOUT<\/code><\/td><td>6<\/td><td>Single-page timeout (seconds)<\/td><\/tr><tr><td><code>CACHE_TTL<\/code><\/td><td>3600<\/td><td>Cache Expiration (seconds)<\/td><\/tr><tr><td><code>RANDOM_DELAY_MIN\/MAX<\/code><\/td><td>5~10<\/td><td>Random delay for search requests (seconds)<\/td><\/tr><tr><td><code>ERROR_COOLDOWN<\/code><\/td><td>60<\/td><td>Cooldown after failure (seconds)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Key Points for Implementing Deep Crawling<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The following was used to extract the body text:<strong>Three-Tier Demotion Strategy<\/strong>::<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>drawing<\/strong>: First choice\u2014offers the highest extraction quality and excellent support for Chinese<\/li>\n\n\n\n<li><strong>readability-lxml<\/strong>: An alternative option from Mozilla with good stability<\/li>\n\n\n\n<li><strong>goose3<\/strong>: A fallback option, suitable for news pages<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">After each crawl, the following will also be performed:<strong>Quality Assessment<\/strong>(text length, percentage of Chinese content, headline quality, etc.); pages with scores that are too low will not have additional content added to them, to avoid introducing noise.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Open WebUI Network Search Configuration<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once the service is launched, it can integrate seamlessly <strong>Open WebUI<\/strong> online search feature. The configuration steps are as follows:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">procedure<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Log in to Open WebUI \u2192 Click the administrator avatar in the lower-left corner \u2192 <strong>Administrator Panel<\/strong>(Admin Panel)<\/li>\n\n\n\n<li>Navigate to <strong>Settings<\/strong> \u2192 <strong>Online Search<\/strong>(Web Search) tab<\/li>\n\n\n\n<li>Fill in the following parameters:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Configuration Options<\/th><th>Recommended Value<\/th><\/tr><\/thead><tbody><tr><td>Search Engine<\/td><td><code>searxng<\/code><\/td><\/tr><tr><td>Searxng Query Interface URL<\/td><td><code>http:\/\/localhost:8888\/search<\/code><\/td><\/tr><tr><td>Number of search results<\/td><td><code>1-3<\/code>(Recommendation 2)<\/td><\/tr><tr><td>Number of concurrent requests<\/td><td><code>0<\/code><\/td><\/tr><tr><td>\u2705 Bypass embedding and retrieval<\/td><td><strong>Open<\/strong><\/td><\/tr><tr><td>\u2705 Bypass the page loader<\/td><td><strong>Open<\/strong><\/td><\/tr><tr><td>Web Page Loading Engine<\/td><td><code>Default<\/code><\/td><\/tr><tr><td>Timeout<\/td><td><code>5<\/code> second<\/td><\/tr><tr><td>SSL Validation<\/td><td><strong>Close<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>Click <strong>Save<\/strong><\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Parameter Description<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Set the number of search results to 1\u20133<\/strong>: When used with the deep crawl feature, setting this value too high may increase response latency. We recommend setting it to 2 to ensure both sufficient information and optimal speed.<\/li>\n\n\n\n<li><strong>Set the number of concurrent requests to 0<\/strong>: Concurrency is controlled internally by this service (<code>DEEP_CRAWL_CONCURRENT<\/code>), to avoid duplicate rate limiting on the Open WebUI side.<\/li>\n\n\n\n<li><strong>Bypassing Embedding and Retrieval<\/strong> + <strong>Bypass the page loader<\/strong>: This service has appended deep-crawled content to <code>content<\/code> Fields\u2014no need for Open WebUI to load an additional page, thereby avoiding duplicate scraping and IP-based access restrictions.<\/li>\n\n\n\n<li><strong>SSL Validation Disabled<\/strong>: This service prevents errors when using self-signed or non-standard certificates (for security in local environments).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Verify whether it is in effect<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Enter a question requiring real-time information (such as \u201cWhat\u2019s in the news today?\u201d) in the chat window and see if it triggers a search request. You can also check the Open WebUI logs to see if there are any <code>http:\/\/localhost:8888\/search<\/code> Call logs.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Important Information and Disclaimer<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>For educational and research purposes only<\/strong>, Please do not use this for commercial purposes or in scenarios involving high-frequency requests<\/li>\n\n\n\n<li>The Baidu Search API essentially simulates browser behavior, so there is a risk of being restricted. Please manage your request frequency appropriately.<\/li>\n\n\n\n<li>We recommend deploying this locally or on an internal network; do not expose it to the public internet.<\/li>\n\n\n\n<li>In-depth crawling may access third-party websites; please respect the target websites' robots.txt files and terms of service.<\/li>\n\n\n\n<li>This project does not store any user data; all caching is used solely to improve response times.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><em>The above configuration is based on Open WebUI version 0.9.x. The interface may vary slightly across different versions, but the core parameters remain the same.<\/em><\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-506b7be9-af36-4cc7-8612-e17882cfb9cd\" href=\"https:\/\/www.livetops.com\/wp-content\/uploads\/2026\/06\/BaiduSearchProxy_OpenWebUI.zip\">BaiduSearchProxy_OpenWebUI<\/a><a href=\"https:\/\/www.livetops.com\/wp-content\/uploads\/2026\/06\/BaiduSearchProxy_OpenWebUI.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-506b7be9-af36-4cc7-8612-e17882cfb9cd\">downloading<\/a><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>","protected":false},"excerpt":{"rendered":"<p>\u7528 Python + Flask \u5b9e\u73b0\u4e00\u4e2a\u517c\u5bb9 SearXNG \u63a5\u53e3\u7684\u672c\u5730\u641c\u7d22\u670d\u52a1\uff0c\u652f\u6301\u6df1\u5ea6\u7f51\u9875\u6293\u53d6 \u80cc\u666f \u5728 [&hellip;]<\/p>","protected":false},"author":1,"featured_media":1552,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"footnotes":""},"categories":[420],"tags":[294,421,418],"class_list":["post-1548","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-python","tag-ai","tag-open-webui","tag-searxng","post_format-post-format-image"],"_links":{"self":[{"href":"https:\/\/www.livetops.com\/en\/wp-json\/wp\/v2\/posts\/1548","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.livetops.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.livetops.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.livetops.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.livetops.com\/en\/wp-json\/wp\/v2\/comments?post=1548"}],"version-history":[{"count":2,"href":"https:\/\/www.livetops.com\/en\/wp-json\/wp\/v2\/posts\/1548\/revisions"}],"predecessor-version":[{"id":1553,"href":"https:\/\/www.livetops.com\/en\/wp-json\/wp\/v2\/posts\/1548\/revisions\/1553"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.livetops.com\/en\/wp-json\/wp\/v2\/media\/1552"}],"wp:attachment":[{"href":"https:\/\/www.livetops.com\/en\/wp-json\/wp\/v2\/media?parent=1548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.livetops.com\/en\/wp-json\/wp\/v2\/categories?post=1548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.livetops.com\/en\/wp-json\/wp\/v2\/tags?post=1548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}