Skip to main content

Web scraping (URLs, images), PubMed search, URL summarization helpers — standalone module from the SciTeX ecosystem

Project description

scitex-web

SciTeX

Web scraping + PubMed search + URL summarization helpers.

Full Documentation · uv pip install scitex-web[all]

PyPI Python Tests Coverage Docs License: AGPL v3


Problem and Solution

# Problem Solution
1 Bulk-fetching links / images means handwriting requests+bs4 boilerplate every project get_urls, get_image_urls, download_images — pattern + min-size + same-domain filters in one call
2 PubMed E-utilities require XML parsing, retries, and pagination — easy to get wrong search_pubmed(query, retmax=N) — returns parsed records; handles pagination + rate limits
3 Skimming an article means opening a tab, grabbing the body, summarizing manually summarize_url(url) — readability extraction + LLM summary (via the SciTeX umbrella)

Architecture

scitex_web/
├── _scrape.py          # get_urls / get_image_urls / download_images
├── _pubmed.py          # search_pubmed (E-utilities client)
├── _summarize.py       # summarize_url (deferred GenAI import)
└── _utils.py           # shared logging + ANSI helpers
flowchart LR
    URL[URL] -->|get_urls / get_image_urls| L[Filtered links]
    L -->|download_images| F[Local files]
    Q[Query string] -->|search_pubmed| R[Parsed PubMed records]
    A[Article URL] -->|summarize_url| S[Summary text]
    S -.uses.-> AI[(scitex.ai.GenAI<br/>deferred import)]
    style F fill:#27ae60,stroke:#2c3e50,color:#fff
    style R fill:#27ae60,stroke:#2c3e50,color:#fff
    style S fill:#27ae60,stroke:#2c3e50,color:#fff

Figure 1. Module layout. Three independent capabilities — scraping, PubMed search, URL summarization. Only summarization needs the umbrella scitex for the GenAI client.

Installation

pip install scitex-web
pip install "scitex-web[readability]"   # readability-lxml for cleaner extraction

Quick Start

import scitex_web as web

results = web.search_pubmed("CRISPR Cas9 review", retmax=5)
images = web.get_image_urls("https://example.com/gallery", min_size=128)

1 Interfaces

Python API
import scitex_web as web

# Scraping
web.get_urls(url, pattern=r"\.pdf$")
web.get_image_urls(url, min_size=128)
web.download_images(url, out_dir="imgs", same_domain=True)

# PubMed
web.search_pubmed("CRISPR Cas9 review", retmax=50)

# URL summarization (requires scitex.ai umbrella)
web.summarize_url("https://example.com/article")

Demo

import scitex_web as web

# 1) Scrape PDFs from a faculty page
pdfs = web.get_urls("https://lab.example.edu/publications", pattern=r"\.pdf$")
#   → ['https://lab.example.edu/papers/2024_smith.pdf', ...]

# 2) Bulk-download figures (same domain, ≥256px)
web.download_images(
    "https://example.com/gallery",
    out_dir="imgs",
    same_domain=True,
    min_size=256,
)

# 3) Search PubMed
records = web.search_pubmed("CRISPR Cas9 review", retmax=5)
for r in records:
    print(r["pmid"], r["title"])

# 4) Summarize an article (requires umbrella scitex)
print(web.summarize_url("https://example.com/article"))
flowchart TD
    Start[Start] --> Want{Goal?}
    Want -- "harvest URLs" --> A[get_urls / get_image_urls]
    Want -- "save images" --> B[download_images]
    Want -- "search literature" --> C[search_pubmed]
    Want -- "summarize article" --> D[summarize_url]
    A --> Out[List / DataFrame]
    B --> Out2[Files on disk]
    C --> Out3[Parsed records]
    D --> Out4[Text summary]
    style Out  fill:#27ae60,stroke:#2c3e50,color:#fff
    style Out2 fill:#27ae60,stroke:#2c3e50,color:#fff
    style Out3 fill:#27ae60,stroke:#2c3e50,color:#fff
    style Out4 fill:#27ae60,stroke:#2c3e50,color:#fff

Figure 2. Demo. Pick a helper by output shape: links, files, records, or summary text.

Status

Standalone fork of scitex.web. Deps: requests / aiohttp / bs4 / tqdm. The umbrella package's scitex.web import path is preserved via a sys.modules-alias bridge.

Decoupling notes:

  • scitex.logging.getLogger → stdlib logging.getLogger.
  • scitex.str.printc (colored print) → tiny inline ANSI helper.
  • scitex.ai.GenAI (used by summarize_url) → deferred import that raises a clear ImportError if the umbrella scitex package isn't installed.

Part of SciTeX

scitex-web is part of SciTeX. Install via the umbrella with pip install scitex[web] to use as scitex.web (Python) or scitex web ... (CLI).

Four Freedoms for Research

  1. The freedom to run your research anywhere — your machine, your terms.
  2. The freedom to study how every step works — from raw data to final manuscript.
  3. The freedom to redistribute your workflows, not just your papers.
  4. The freedom to modify any module and share improvements with the community.

AGPL-3.0 — because we believe research infrastructure deserves the same freedoms as the software it runs on.

License

AGPL-3.0-only (see LICENSE).


SciTeX

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

scitex_web-0.1.5.tar.gz (34.1 kB view details)

Uploaded Source

Built Distribution

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

scitex_web-0.1.5-py3-none-any.whl (34.6 kB view details)

Uploaded Python 3

File details

Details for the file scitex_web-0.1.5.tar.gz.

File metadata

  • Download URL: scitex_web-0.1.5.tar.gz
  • Upload date:
  • Size: 34.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scitex_web-0.1.5.tar.gz
Algorithm Hash digest
SHA256 b5f69412e5df7aa5b63547b40ecd3c0215d81d60a41184a43b5726b2d12daac7
MD5 5e8cb8c91c6e60e6a61f08ee9f260ea6
BLAKE2b-256 851b133ffc46b6ac3fd71e28f7d561206f5dbd02f384dfb81760c5cce9548da7

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_web-0.1.5.tar.gz:

Publisher: pypi-publish-and-github-release-on-tag.yml on ywatanabe1989/scitex-web

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scitex_web-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: scitex_web-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 34.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scitex_web-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 be0e2ed16dd17eda83725df04b91ce5341d9b308c1c1ba642366c297effc4bd0
MD5 72d17a1272f094d1dd1176cfe8308577
BLAKE2b-256 0a4e3e7055e3a8d2ff24f49e9d64e132385f2686f2648d89081e31b4be66be55

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_web-0.1.5-py3-none-any.whl:

Publisher: pypi-publish-and-github-release-on-tag.yml on ywatanabe1989/scitex-web

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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