Skip to main content

PySerp

PyPI Python Versions License

PySerp is an asynchronous Python library for automated, flexibly configurable scraping and parsing of Search Engine Results Pages (SERPs).

Purpose

Scraping search engine results is almost always necessary when the task is to automatically analyze these results, or to collect content from the links within them for any purpose.

Examples:

  • Competitive analysis for keywords (SEO)
  • Searching for and extracting any structured information from page content (phone numbers, emails, addresses, etc)
  • Collecting page content to generate summaries (AI search)

Key Features

This library:

  • Is asynchronous by default for maximum efficiency
  • Supports Google and Bing as search engines (more will be added in the future)
  • Applies strict typing to results using Pydantic

Installation

Simply run:

pip install pyserp

From Source (Development)

If you want to contribute or use the latest git version, download the source code:

git clone https://github.com/whode/pyserp
cd pyserp

Create a virtual environment (recommended):

python -m venv venv

And activate it

On Linux:

source venv/bin/activate

On Windows:

venv\Scripts\activate

Install the library:

pip install -e .

Usage

A simple, idiomatic usage example that demonstrates retrieving the top 10 search results from Google for a given query:

import asyncio

from pyserp.providers import GoogleSearcherManager, GoogleSearchSessionsManager


async def main():
    query = "how to learn python"
    print("Searching for:", query, end="\n\n")

    cookies = {"NID": "YOUR_NID_COOKIE (Get it in your browser (but not Chrome): F12 -> Application -> Cookies)"}
    manager = GoogleSearchSessionsManager(cookies = cookies)
    async with GoogleSearcherManager(search_sessions_manager=manager) as searcher:
        search_top_result = await searcher.search_top(query=query,
                                                      limit=10,
                                                      include_page_errors=False)

        print("----- Results -----", end="\n\n")
        for page in search_top_result.pages:
            for result in page.results.organic:
                print(result.title, result.url, sep="\n", end="\n\n")


if __name__ == "__main__":
    asyncio.run(main())

The library offers much more than this. Full documentation will be added in the future.

Development & Testing

Tests are included in the source repository only (not in the PyPI package). To run tests, first follow the steps in "From Source (Development)" above. Then:

pip install -U pytest
python -m pytest

Metadata

Release files for pyserp 1.0.2.post2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyserp 1.0.2.post2
File Size Uploaded Provenance Actions
pyserp-1.0.2.post2.tar.gz 23.5 kB Without provenance Details for pyserp-1.0.2.post2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyserp 1.0.2.post2
File Interpreter ABI Platform Actions
pyserp-1.0.2.post2-py3-none-any.whl Python 3 none any Details for pyserp-1.0.2.post2-py3-none-any.whl

Total release size: 59.5 kB

Release files / pyserp-1.0.2.post2.tar.gz

Download URL pyserp-1.0.2.post2.tar.gz
Size 23.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0c49a971acaa78b32a4d1b64a03caa3316496b4eb88320ce7c8d5417ff52834e
BLAKE2b-256 checksum
How to use checksums
ff810ab8cefe0d5f3bd98cc4764de5e7e0e7eeb14c260193574ac929fe53a62a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release files / pyserp-1.0.2.post2-py3-none-any.whl

Download URL pyserp-1.0.2.post2-py3-none-any.whl
Size 36.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51a581e5c12b1e94c505c1b3801f1f8c9e073c8945f3cbd1da909e22c203f46b
BLAKE2b-256 checksum
How to use checksums
e58ae24acb57daf5b16355df2d0d725b0b578d0f6dacc59dd72903f42fb01b82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Security for pyserp 1.0.2.post2

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page