Skip to main content

A fast, multi-source web search library with intelligent fallback and content extraction.

Project description

🚀 Flash-search

A fast, multi-source web search library with intelligent fallback and content extraction capabilities.

PyPI Python 3.6+ License: MIT

Features

Core Features

Fast Web Search - Search across multiple sources with intelligent fallback (Google + DuckDuckGo)
🔄 Auto Fallback - Automatically uses DuckDuckGo if Google is blocked
📄 Content Extraction - Extract clean, readable text from websites without HTML
💾 Save Results - Export search results and website content to .txt files
🌍 Multi-language - Support for 30+ languages and regions
🔧 Advanced Filtering - Unique results, safe search, pagination support
Fast Performance - Optimized with curl-cffi for speed and reliability

Advanced Features

🎯 Query Intent Detection - Automatically detect search intent (Informational, Navigational, Transactional, Local) for better result ranking
🏆 Smart Ranking Algorithm - Advanced ranking engine that scores results based on keyword matching, URL quality, and domain authority
Content Quality Assessment - Evaluate content quality based on title optimization, description comprehensiveness, and URL structure
🌈 Result Diversification - Smart result diversification to provide varied and comprehensive search results

Installation

pip install flash-search

Quick Start

Basic Search

from flash_search import search

# Get search result URLs
for url in search("Python programming", num_results=5):
    print(url)

Advanced Search

from flash_search import search

# Get detailed results with title and description
for result in search("Machine Learning", num_results=5, advanced=True):
    print(f"Title: {result.title}")
    print(f"URL: {result.url}")
    print(f"Description: {result.description}\n")

Extract Website Content

from flash_search import extract_website_content

# Get clean text from a website
content = extract_website_content("https://example.com")
print(content)

Save Results to File

from flash_search import search, save_results_to_file

# Search and save results
results = list(search("Python", num_results=10, advanced=True))
save_results_to_file(results, "results.txt")

Save Website Content

from flash_search import save_website_content

# Extract and save website content
save_website_content("https://python.org", "python_org.txt")

API Reference

search(term, **kwargs)

Search the web for a query.

Parameters:

  • term (str): Search query
  • num_results (int): Number of results to return (default: 10)
  • lang (str): Language code (default: "en")
  • advanced (bool): Return SearchResult objects instead of URLs (default: False)
  • timeout (int): Request timeout in seconds (default: 5)
  • unique (bool): Return only unique results (default: False)
  • proxy (str): Proxy URL if needed
  • safe (str): Safe search ("active" or None)
  • region (str): Country code for region-specific results

Returns: Generator yielding URLs or SearchResult objects

extract_website_content(url)

Extract clean text from a website.

Parameters:

  • url (str): Website URL

Returns: Clean text content

save_results_to_file(results, filename)

Save search results to a file.

Parameters:

  • results (list): Search results to save
  • filename (str): Output filename

save_website_content(url, filename=None)

Extract and save website content.

Parameters:

  • url (str): Website URL
  • filename (str): Output filename (auto-generated if None)

Advanced Features Documentation

Query Intent Detection

Automatically detect the intent behind a search query to improve result ranking.

from Query_Intent_Detection import detect_intent, SearchIntent

# Detect search intent
intent = detect_intent("How to learn Python")
print(intent)  # SearchIntent.INFORMATIONAL

# Supported intents:
# - INFORMATIONAL: "How to...", "What is...", "Explain"
# - NAVIGATIONAL: Brand or site-specific searches
# - TRANSACTIONAL: "Buy...", "Price...", "Download"
# - LOCAL: "Near me", location-based searches

Smart Ranking Algorithm

Score and rank search results based on relevance factors.

from Ranking_Algorithm import SearchRanker

ranker = SearchRanker()

# Score a single result
score = ranker.score_result("Python tutorial", search_result)
print(f"Relevance Score: {score}")

# Ranking considers:
# - Keyword matching in title (100 points)
# - Keyword matching in description (50 points)
# - URL quality check (30 points)
# - Domain authority (up to 20 points)

Content Quality Assessment

Evaluate the quality of search results based on various metrics.

from Content_Quality_Assessment import assess_content_quality

# Assess quality of a result
quality_score = assess_content_quality(
    title="Complete Python Programming Guide",
    description="A comprehensive guide covering Python basics...",
    url="https://example.com/python-guide"
)
print(f"Quality Score: {quality_score}")  # 0-100

# Factors considered:
# - Title length optimization (20 points)
# - Description comprehensiveness (20 points)
# - Content validity check (20 points)
# - URL readability (20 points)
# - Content freshness (20 points)

Result Diversification

Get diverse search results covering multiple aspects of your query.

from Result_Diversification import diversify_results

# Diversify results to cover different aspects
diverse_results = diversify_results(results, max_per_domain=2)
print(f"Original results: {len(results)}")
print(f"Diversified results: {len(diverse_results)}")

How It Works

Flash-search uses a comprehensive multi-layered approach:

  1. Primary Source: Uses curl-cffi to impersonate a real browser and fetch Google results
  2. Fallback Source: Automatically switches to DuckDuckGo if Google blocks the request
  3. Intent Detection: Analyzes the search query to understand user intent and optimize ranking
  4. Smart Ranking: Scores results based on keyword relevance, URL quality, and domain authority
  5. Quality Assessment: Evaluates content quality using multiple factors
  6. Result Diversification: Ensures varied results from different sources and domains

This multi-layered approach ensures reliable, relevant, and diverse search results.

Requirements

  • Python 3.6+
  • beautifulsoup4 >= 4.9
  • requests >= 2.20
  • curl-cffi >= 0.5.0
  • ddgs >= 9.0.0
  • fake-useragent >= 1.0.0

Troubleshooting

Search returns no results:

  • Check your internet connection
  • Try increasing sleep_interval to avoid rate-limiting
  • The website structure may have changed

"DuckDuckGo fallback not available":

pip install ddgs

License

MIT License - See LICENSE file for details

Disclaimer

This tool is for educational and research purposes. Please respect website terms of service and robots.txt when scraping.

- description

If requesting more than 100 results, googlesearch will send multiple requests to go through the pages. To increase the time between these requests, use `sleep_interval`:
```python
from googlesearch import search
search("Google", sleep_interval=5, num_results=200)
If requesting more than 10 results, but want to manage the batching yourself? 
Use `start_num` to specify the start number of the results you want to get:
```python
from googlesearch import search
search("Google", sleep_interval=5, num_results=200, start_num=10)

If you are using a HTTP Rotating Proxy which requires you to install their CA Certificate, you can simply add ssl_verify=False in the search() method to avoid SSL Verification.

from googlesearch import search


proxy = 'http://username:password@proxy.host.com:8080/'
# or for socks5
# proxy = 'socks5://username:password@proxy.host.com:1080/'

j = search("proxy test", num_results=100, lang="en", proxy=proxy, ssl_verify=False)
for i in j:
    print(i)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flash_search-2.5.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flash_search-2.5.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file flash_search-2.5.0.tar.gz.

File metadata

  • Download URL: flash_search-2.5.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for flash_search-2.5.0.tar.gz
Algorithm Hash digest
SHA256 df6f33fea4c5cd0a9843a3ace5835cf2b34ab46c62d7c3d136e9b4abb718d438
MD5 9ceb94fde023a96e9bcfbab77953c61c
BLAKE2b-256 f9fbb3d28b56d4b1b06e02e5fdf5695e75d7ba77b805e9660a97fdeddc53774c

See more details on using hashes here.

File details

Details for the file flash_search-2.5.0-py3-none-any.whl.

File metadata

  • Download URL: flash_search-2.5.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for flash_search-2.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c29b3d65500558874ba4e868aad6bf9bed8580985ccf2834df6c11721d67869
MD5 7546046bb40612a6120df9f3e1eaf5e7
BLAKE2b-256 fd33dba070e4726482259c23e9ec1ff9a64bc95454450ffffcdfa8b2342aefe0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page