import pywikibot

from pywikibot import pagegenerators as pg

def list_template_usage(site_obj, tmpl_name):
    Takes Site object and template name and returns a generator.

    The function expects a Site object (pywikibot.Site()) and
    a template name (String). It creates a list of all
    pages using that template and returns them as a generator.
    The generator will load 50 pages at a time for iteration.
    name = "{}:{}".format(site_obj.namespace(10), tmpl_name)
    tmpl_page = pywikibot.Page(site_obj, name)
    ref_gen = pg.ReferringPageGenerator(tmpl_page, onlyTemplateInclusion=True)
    filter_gen = pg.NamespaceFilterPageGenerator(ref_gen, namespaces=[0])
    generator = site_obj.preloadpages(filter_gen, pageprops=True)
    return generator

site = pywikibot.Site("en", 'wikipedia')
tmpl_gen = list_template_usage(site, "Infobox meteorite")

for page in tmpl_gen:
    item = pywikibot.ItemPage.fromPage(page)
    print(page.title(), item.getID())
Retrieving 50 pages from wikipedia:en.
Wold Cottage meteorite Q4053207
Allan Hills 84001 Q47580
Campo del Cielo Q1031478
Sayh al Uhaymir 169 Q2228546
Sikhote-Alin meteorite Q652204
Willamette Meteorite Q962600
Heat Shield Rock Q610553
Canyon Diablo (meteorite) Q1034024
High Possil meteorite Q5756223
Orgueil (meteorite) Q3131804
Cape York meteorite Q1034516
Murchison meteorite Q1164183
Imilac Q6004059
Paragould meteorite Q7134640
Old Woman meteorite Q4045713
Tagish Lake (meteorite) Q1640697
Hoba meteorite Q216876
Kaidun meteorite Q1298625
Fukang (meteorite) Q5507580
Chassigny (meteorite) Q174066
Nakhla meteorite Q1082769
Yamato 791197 Q8047974
Shergotty meteorite Q2975736
Chinguetti meteorite Q5101045
Karoonda meteorite Q1626872
Adelie Land meteorite Q355052
Hadley Rille meteorite Q261837
Peekskill meteorite Q1477392
Beardsley meteorite Q4876692
Bench Crater meteorite Q2895690
Allende meteorite Q1930079
Stannern (meteorite) Q1968101
Gibeon (meteorite) Q1522908
Sylacauga (meteorite) Q2564923
Brahin (meteorite) Q897277
Esquel (meteorite) Q5399225
Brenham (meteorite) Q4096315
Homestead (meteorite) Q4040725
L'Aigle (meteorite) Q1880589
Krasnojarsk (meteorite) Q427535
Huckitta (meteorite) Q5928087
Monte Milone (meteorite) Q15255597
Omolon (meteorite) Q4334665
Mineo (meteorite) Q3858361
Norton County (meteorite) Q4045484
Ourique (meteorite) Q15264763
Pultusk (meteorite) Q4047637
Pavlovka (meteorite) Q3583079
Qidong (meteorite) Q7267696
Park Forest (meteorite) Q5971067
Retrieving 50 pages from wikipedia:en.
Gao–Guenie meteorite Q176241
Pallasovka (meteorite) Q7127754
Seymchan (meteorite) Q2275869
Ensisheim (meteorite) Q1344365
Albareto (meteorite) Q3607897
Buzzard Coulee meteorite Q5003569
Tenham (meteorite) Q7699844
Mbozi meteorite Q4382614
Bovedy (meteorite) Q4950516
Chergach Q5091898
Yardymly (meteorite) Q4538523
Kesen meteorite Q1966720
Abee (meteorite) Q318284
Adhi Kot (meteorite) Q4682525
Appley Bridge meteorite Q4781441
Aarhus (meteorite) Q3583039
Andura Q4760315
Archie (meteorite) Q4786601
Agen (meteorite) Q4691978
Allegan (meteorite) Q4731221
Ambapur Nagla Q4741017
Anlong (meteorite) Q4766142
Arbol Solo (meteorite) Q4784741
Arroyo Aguiar (meteorite) Q4796226
Assisi (meteorite) Q4808928
Akbarpur (meteorite) Q4700483
Ankober (meteorite) Q4766088
Avanhandava (meteorite) Q4827653
Chambord meteorite Q5069701
Neuschwanstein (meteorite) Q1981433
St-Robert meteorite Q7586657
Penouille meteorite Q15265917
Lac Dodon Q6467828
Veliky Ustyug (meteorite) Q4106567
Weston meteorite Q4053060
Elbogen (meteorite) Q4037970
Moss meteorite Q6916610
Annaheim meteorite Q4767789
Oileán Ruaidh (Mars rock) Q7081488
Angers (meteorite) Q4763139
Springwater meteorite Q4049972
Benton meteorite Q4890639
Blithfield meteorite Q4926933
Osseo meteorite Q7107430
Gay Gulch meteorite Q5528588
Peace River (meteorite) Q7157430
Yamato 691 Q4537600
Middlesbrough meteorite Q6841881
Toluca (meteorite) Q1625058
Adzhi-Bogdo Q4686953
Retrieving 50 pages from wikipedia:en.
Hraschina meteorite Q728624
Muonionalusta Q6937085
Claxton meteorite Q4984880
Tissint meteorite Q3333926
Treysa (meteorite) Q875469
Sutter's Mill meteorite Q1587292
Goose Lake meteorite Q4039603
Loreto (meteorite) Q6680892
Atoka meteorite Q4817176
Grant meteorite Q5596601
Chinga meteorite Q614594
Novato meteorite Q7064495
Carancas meteorite Q5037689
Dronino meteorite Q897501
Brachina meteorite Q4953288
Nantan meteorite Q351033
Zaklodzie meteorite Q144748
Eagle Station meteorite Q5325264
Itqiy meteorite Q1449768
Tamdakht meteorite Q1532797
Santa Vitoria do Palmar meteorite Q1591644
Tlacotepec meteorite Q7810691
Richardton meteorite Q1364761
Příbram meteorite Q939754
Bellsbank meteorite Q4884167
Oldenburg meteorite Q1971281
Northwest Africa 3009 Q1240766
Twannberg meteorite Q1542807
Coahuila meteorite Q4036340
Cranbourne meteorite Q1138829
Vermillion meteorite Q7921633
Winona meteorite Q8025899
Angra dos Reis meteorite Q4763888
Northwest Africa 7034 Q2596468
Ornans (meteorite) Q7103521
Shelter Island meteorite Q4049389
Block Island meteorite Q4035204
Mackinac Island meteorite Q4043551
D'Orbigny meteorite Q5203167
Mundrabilla (meteorite) Q6935888
Millbillillie (meteorite) Q1169408
Gebel Kamil (meteorite) Q5529550
Zaisho Q8064892
Kainsaz meteorite Q1721470
Polonnaruwa (meteorite) Q7225953
Chelyabinsk meteorite Q4980823
Sołtmany (meteorite) Q4985109
Baszkówka (meteorite) Q4984351
Białystok (meteorite) Q4985106
Łowicz (meteorite) Q4043234
Retrieving 12 pages from wikipedia:en.
Allan Hills A81005 Q5379096
Sulagiri (meteorite) Q7635946
Northwest Africa 7325 Q4162207
Yamato 000593 Q15888151
Bacubirito Meteorite Q18209819
Santa Rosa de Viterbo Meteorite Q18354908
Lake Murray Meteorite Q18154197
Port Orford meteorite hoax Q23018424
Österplana 065 Q24658624
Los Angeles (meteorite) Q25006284
Zagami meteorite Q9385821
Gancedo (meteorite) Q26878625