Skip to main content

Fetch PubMed papers with non-academic authors

Project description

PubMed Scraper

A command-line tool to fetch research papers from PubMed based on a user-specified query. The tool identifies papers with at least one author affiliated with a pharmaceutical or biotech company and outputs the results as a CSV.

Features

  • Fetches papers using the PubMed E-utilities API
  • Filters authors affiliated with biotech/pharmaceutical companies
  • Saves results as CSV or prints to console
  • Supports full PubMed query syntax
  • Easy CLI usage
  • Installable as a Python package

Installation (from TestPyPI)

pip install --index-url https://test.pypi.org/simple/ pubmed-scraper

From Source

  1. Clone the repository:
    git clone https://github.com/Rashijain2709/pubmed_scraper.git
    cd pubmed_scraper
    

Tools Used

Tool Purpose
[Poetry] Dependency management and packaging
[Requests] Making HTTP requests to the PubMed API
[argparse] CLI argument parsing
[Python Typing] Type hints and type safety
[pytest] Unit testing

Project Structure

pubmed_scraper/
│
├── cli/                      # CLI entry point logic
│   └── main.py               # Contains CLI commands (argparse/typer/click)
│
├── src/
│   └── pubmed_scraper/       # Installable Python package
│       ├── __init__.py
│       ├── api.py            # Handles PubMed API requests
│       ├── parser.py         # Parses XML or JSON responses
│       ├── writer.py         # Writes results to CSV
│
├── tests/                    # Unit tests
│   └── test_parser.py
│
├── pyproject.toml            # Poetry project configuration
├── README.md                 # Project documentation
└── .gitignore                # (Recommended) Git ignore patterns


Poetry Project Execution Guide

This guide helps you set up, test, and publish your PubMed scraper project using Poetry and TestPyPI.


1. Initial Setup

Install required dependencies and dev tools:

poetry add requests

poetry add pytest --dev

poetry install

2. Check and Lock Dependencies

poetry check

poetry lock

3. Run Tests

poetry run pytest

4. Configure TestPyPI

poetry config repositories.test-pypi https://test.pypi.org/legacy/

# Verify the configuration (Windows)
poetry config --list | findstr pypi

# On macOS/Linux
poetry config --list | grep pypi

5. Build the Package

# Optional: Clean previous builds
rm -r dist/*   # Use 'rmdir /S /Q dist' on Windows

# Build the package
poetry build

6. Publish to TestPyPI

# Publish the package to TestPyPI
poetry publish --build -r test-pypi

7. Run Your Program

# Run the scraper with a query and output file
poetry run get-papers-list "cancer immunotherapy" --file papers.csv --debug

# Another example
poetry run get-papers-list "cancer therapy" --file results.csv --debug

Optional: Clean and Rebuild Everything

rm -r dist/*
poetry build
poetry publish --build -r test-pypi

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

pubmed_scraper_rashi-0.1.3.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

pubmed_scraper_rashi-0.1.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file pubmed_scraper_rashi-0.1.3.tar.gz.

File metadata

  • Download URL: pubmed_scraper_rashi-0.1.3.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.5 Windows/10

File hashes

Hashes for pubmed_scraper_rashi-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f49d52ee21178e3a6368255c8cdbf062bc87e0f0290a0a581103cedf53e8e7f0
MD5 f43181f3251221cba5c10dac5e52e8ac
BLAKE2b-256 ad110cc5b36a7e2e19c8b786f507073a952b5554cbfe791eea39a54298453717

See more details on using hashes here.

File details

Details for the file pubmed_scraper_rashi-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pubmed_scraper_rashi-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6f3b91c80fae9e7731e0d1603f9875cd9a974017917164034e8388b7d38c5a68
MD5 6b5e6e1f0c840672826a9f341ef7770c
BLAKE2b-256 8e8d80c8f2a2fb406ac4e3ffbf7a4db22a634895845847765a381218d2b8ff98

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