Query and scrape search engines (Google, Google News, Yahoo, Yahoo News, Bing, Bing News, Ask, Dogpile, Dogpile News)
Installation
pip install search_engines
Overview
Each search engine has a module {engine_name}.py which two functions:
extract_search_results(html: str, page_url: str) -> Tuple[List[Dict[str, str]], str]
and
get_search_url(query: str, latest: bool = True, country: str = 'us') -> str
Usage Example
Construct a URL for the first results page of searching "Tesla TSLA" in Bing Search.
from search_engines import bing_search
url = bing_search.get_search_url('Tesla TSLA')
Load the URL using a simple HTTP client or web browser and extract the page HTML.
This package does not make any restrictions on clients can be used. We'll use the requests library for this example.
import requests
resp = requests.get(url)
html = resp.text
We can now extract search results from the HTML.
The returned results list will be a list of dictionaries with keys url, title, preview_text, page_number.
If we want to scrape multiple pages, we can load the next page using the returned next_page_url, and again extracting the results using extract_search_results.
results, next_page_url = bing_search.extract_search_results(html, url)
Contributions
Add new search engines! =)
Metadata
Release files for search-engines 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| search_engines-1.0.7.tar.gz | 5.8 kB | Without provenance | Details for search_engines-1.0.7.tar.gz |
Release files / search_engines-1.0.7.tar.gz
| Download URL | search_engines-1.0.7.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ec8181daca92a085cccdb46ef28bfb59662f7eff3fbef206e50a32171b384fb
|
|
BLAKE2b-256 checksum How to use checksums |
ba326c85afb363fdd1bcc045371938449c4de430d1fa7e6d90087be164c35df6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5
|
Security for search-engines 1.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.