Skip to content

Add support for command line #19

@pkienzle

Description

@pkienzle

You could provide __main__.py so that you can call it from the command line with a scholar id or url

Something like the following:

import sys
from urllib.parse import urlparse, parse_qs

from coapy.scholar import get_coauthors

if len(sys.argv) != 2:
    print("Usage: python -m coapy \"SCHOLAR_ID or URL\"")
    sys.exit()

scholar_id = sys.argv[1]
outfile = "coauthors.csv"

if "scholar.google.com/" in scholar_id:
    # We've been given a link. Extract the scholar id
    scholar_id = parse_qs(urlparse(scholar_id).query)["user"][0]

get_coauthors(scholar_id=scholar_id, years_back=4, filename=outfile)
print(f"saved to {outfile}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions