Skip to main content

PyScholarly

An async Python library for scraping Google Scholar profiles using Playwright, with support for proxy rotation and detailed citation tracking.

⚠️ Disclaimer: This project is for academic and research purposes only. Please be mindful of Google Scholar's terms of service and rate limiting. Use responsibly and at your own risk.

Installation

pip install pyscholarly

Features

  • Async/await support for efficient data fetching
  • Proxy support with rotation strategies:
    • Sequential rotation
    • Random rotation
    • Support for authenticated proxies (username/password)
  • Comprehensive citation metrics:
    • All-time citations
    • Recent citations (last 5 years)
    • Year-to-date citations per publication
    • H-index and i10-index (all-time and recent)
  • Publication details:
    • Title, authors, venue, year
    • Citation counts (all-time and YTD)
  • Debug logging and HTML page saving for troubleshooting
  • Headless mode support
  • Modern Playwright-based scraping

Usage

Basic Usage

from pyscholarly import fetch_scholar_data
import asyncio

async def main():
    # Fetch data for a Google Scholar profile
    author_id = "SCHOLAR_ID"  # Replace with actual Google Scholar ID
    data = await fetch_scholar_data(author_id)
    
    print(f"Author: {data['name']}")
    print(f"Total citations: {data['citedby']}")
    print(f"Recent citations: {data['citedby_recent']}")
    print(f"h-index: {data['hindex']}")
    
    # Print publications with YTD citations
    print("\nPublications:")
    for pub in data['publications']:
        print(f"- {pub['bib']['title']} ({pub['year']}):")
        print(f"  - Total citations: {pub['num_citations']}")
        print(f"  - YTD citations: {pub['ytd_citations']}")

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

Advanced Usage with Proxies

import logging
from pyscholarly import fetch_scholar_data

# Setup logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

async def main():
    # Single proxy
    proxy = "username:password@host:port"
    
    # Or multiple proxies
    proxies = [
        "username1:password1@host1:port1",
        "username2:password2@host2:port2"
    ]
    
    data = await fetch_scholar_data(
        scholar_id="SCHOLAR_ID",
        proxies=proxies,
        proxy_rotation="random",  # or "sequential"
        headless=True,
        logger=logger
    )

Return Data Structure

{
    'name': str,
    'citedby': int,              # All-time citations
    'citedby_recent': int,       # Citations in last 5 years
    'hindex': int,               # All-time h-index
    'hindex_recent': int,        # Recent h-index
    'i10index': int,             # All-time i10-index
    'i10index_recent': int,      # Recent i10-index
    'publications': [
        {
            'bib': {
                'title': str,
                'authors': str,
                'venue': str
            },
            'num_citations': int,    # Total citations
            'ytd_citations': int,    # Year-to-date citations
            'year': str
        },
        # ...
    ]
}

Configuration Options

Parameter Type Description
scholar_id str Google Scholar profile ID
proxies Optional[Union[str, List[str]]] Single proxy or list of proxies
proxy_rotation str Proxy rotation strategy ('sequential' or 'random')
headless bool Run browser in headless mode
logger Optional[Logger] Custom logger instance

Requirements

  • Python 3.8+
  • Playwright

Debug Mode

The library saves HTML pages for debugging purposes in a debug_pages directory when running with a logger at DEBUG level.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for pyscholarly 0.1.77

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

Source distribution (sdist)

Source distribution for pyscholarly 0.1.77
File Size Uploaded Provenance
pyscholarly-0.1.77.tar.gz 8.9 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 16.5 kB

Release files / pyscholarly-0.1.77.tar.gz

Download URL pyscholarly-0.1.77.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
afea0cc5c08eeefcfd8a593a8dbd290f018012554fd0a0280b903b6d048bd83f
BLAKE2b-256 checksum
How to use checksums
c9348eec995d4b7ca9596b90afccefcfc6e54f33389eff7b5e800e933dfce242
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.5

Release files / pyscholarly-0.1.77-py3-none-any.whl

Download URL pyscholarly-0.1.77-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa62ce235e514b0d240594bfb376dcec14c7ae03d8548800b127d7ff24ee8b80
BLAKE2b-256 checksum
How to use checksums
64845def9ca1783af2d7b9e3598fa8a0618cc5b1c67b443687092df1106f722c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.5

Security for pyscholarly 0.1.77

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