Skip to main content

📦 Parsera

Discord Downloads

Lightweight Python library for scraping websites with LLMs. You can test it on Parsera website.

Why Parsera?

Because it's simple and lightweight. With interface as simple as:

scraper = Parsera()
result = scraper.run(url=url, elements=elements)

Table of Contents

Installation

pip install parsera
playwright install

Documentation

Check out documentation to learn more about other features, like running custom models and playwright scripts.

Basic usage

First, set up PARSERA_API_KEY env variable (If you want to run custom LLM see Custom Models). You can do this from python with:

import os

os.environ["PARSERA_API_KEY"] = "YOUR_PARSERA_API_KEY_HERE"

Next, you can run a basic version:

from parsera import Parsera

url = "https://news.ycombinator.com/"
elements = {
    "Title": "News title",
    "Points": "Number of points",
    "Comments": "Number of comments",
}

scraper = Parsera()
result = scraper.run(url=url, elements=elements)

result variable will contain a json with a list of records:

[
   {
      "Title":"Hacking the largest airline and hotel rewards platform (2023)",
      "Points":"104",
      "Comments":"24"
   },
    ...
]

There is also arun async method available:

result = await scrapper.arun(url=url, elements=elements)

Running with Jupyter Notebook:

Either place this code at the beginning of your notebook:

import nest_asyncio
nest_asyncio.apply()

Or instead of calling run method use async arun.

Running with CLI

Before you run Parsera as command line tool don't forget to put your OPENAI_API_KEY to env variables or .env file

Usage

You can configure elements to parse using JSON string or FILE. Optionally, you can provide FILE to write output and amount of SCROLLS, that you want to do on the page

python -m parsera.main URL {--scheme '{"title":"h1"}' | --file FILENAME} [--scrolls SCROLLS] [--output FILENAME]

Running in Docker

In case of issues with your local environment you can run Parsera with Docker, see documentation.

Metadata

Release files for parsera 0.2.6

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

Source distribution (sdist)

Source distribution for parsera 0.2.6
File Size Uploaded
parsera-0.2.6.tar.gz 20.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for parsera 0.2.6
File Interpreter ABI Platform
parsera-0.2.6-py3-none-any.whl Python 3 none any Details

Total release size: 44.2 kB

Release files / parsera-0.2.6.tar.gz

Download URL parsera-0.2.6.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
60df463655345d2fb50062e611902d103f7ae2616bf9924c1d8efc90f889d398
BLAKE2b-256 checksum
How to use checksums
77909ddc9ec4b801b806c2952abb779968b08215a6e945b5f613933eca40ab4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.13.7 Darwin/24.6.0

Release files / parsera-0.2.6-py3-none-any.whl

Download URL parsera-0.2.6-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2690c0a85a7d4e201921897476564b16c2fd1c25bbd6de65451e0b4b413c686
BLAKE2b-256 checksum
How to use checksums
eb4e42bb092758910c8ea218ff536014bc9cc5b6ab0238618b35a752f782dbcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.13.7 Darwin/24.6.0

Release history Release notifications | RSS feed

This release

0.2.6 This release

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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