4

I want to access the Wikipedia infobox image for a given article title in a python program.Can someone please tell me how do I get that?

The following snipped gives list of all images in the page.I want to access just the infobox image.How do I do that?

import wikipedia
ny=wikipedia.page("Sachin Tendulkar")
print ny.images
Aubrey
  • 507
  • 4
  • 20
user1985948
  • 291
  • 1
  • 13

1 Answers1

1

I will assume you are using wikipedia.py, the Python API wrapper (the example you make is from the documentation).

Actually, the docs say exactly what you need: you have to check if the picture in the infobox is the first one (or second, third, etc.) one (I would say it is often, if not always, the first).

print ny.images[0]
HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
Aubrey
  • 507
  • 4
  • 20