mediawikiwikipedia-apimediawiki-apipywikibot

Get links from summary section of wikipedia page


I am trying to extract links from the summary section of a wikipedia page. I tried the below methods :

This url extracts all the links of the Deep learning page: https://en.wikipedia.org/w/api.php?action=query&prop=links&titles=Deep%20learning

And for extracting links associated to any section I can filter based on the section id - for e.g.,

for the Definition section of same page I can use this url : https://en.wikipedia.org/w/api.php?action=parse&prop=links&page=Deep%20learning&section=1

for the Overview section of same page I can use this url : https://en.wikipedia.org/w/api.php?action=parse&prop=links&page=Deep%20learning&section=2

But I am unable to figure out how to extract only the links from summary section

enter image description here

I even tried using pywikibot to extract linkedpages and adjusting plnamespace variable but couldn't get links only for summary section.


Solution

  • You need to use https://en.wikipedia.org/w/api.php?action=parse&prop=links&page=Deep%20learning&section=0

    Note that this also includes links in the {{machine learning bar}} and {{Artificial intelligence|Approaches}} templates however (to the right of the screen).