import os from mwclient import Site from pprint import pprint site = Site(host='hub.xpub.nl/sandbox', path='/itchwiki/') wd = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # parent working directory with open(os.path.join(wd, 'login.txt'), 'r') as login: # read login user & pwd loginlines = login.read() user, pwd = loginlines.split('\n') site.login(username=user, password=pwd) # login to wiki print(site) for n, img in enumerate(site.allimages()): if n < 5: print(img) print('Image attributes:') pprint(img.__dict__) # info contained in each img object print('Image object methods:', dir(img)) # important img info to dictionary print(img.name, img.page_title, img.imageinfo['timestamp'], img.imageinfo['url'], img.imageinfo['descriptionshorturl']) print('\n')