martin-majlis / Wikipedia-API

Python wrapper for Wikipedia
MIT License
603 stars 78 forks source link

Make available the page ID property #70

Closed bkowshik closed 3 months ago

bkowshik commented 1 year ago

Ref: https://en.wikipedia.org/w/index.php?title=Modified_Newtonian_dynamics&action=info

Every Wikipedia page has a Page ID property. Can we expose this as a property in the Python page object?

Screenshot 2023-09-17 at 16 51 02

Update: For now, I have gone ahead with the solution listed here: https://stackoverflow.com/a/67112472/9331359

url = 'https://en.wikipedia.org/w/api.php?action=query&prop=pageprops&titles=Modified Newtonian dynamics&format=json'
response = requests.get(url)
print(json.dumps(json.loads(response.text), indent=4))

{
    "batchcomplete": "",
    "query": {
        "pages": {
            "21591425": {
                "pageid": 21591425,
                "ns": 0,
                "title": "Modified Newtonian dynamics",
                "pageprops": {
                    "wikibase-shortdesc": "Hypothesis proposing a modification of Newton's laws",
                    "wikibase_item": "Q1503556"
                }
            }
        }
    }
}
github-actions[bot] commented 3 months ago

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 3 months ago

This issue was closed because it has been stalled for 10 days with no activity.