SHARE
TWEET

Untitled

a guest Jan 26th, 2019 169 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -*- coding: utf-8 -*-
  2. import requests
  3.  
  4. username = 'produnis@pdfexort'
  5. password = 'SECRET' # see https://www.mediawiki.org/wiki/Manual:Bot_passwords
  6. api_url = 'http://192.168.0.4/produniswiki/api.php'
  7.  
  8. session = requests.Session()
  9.  
  10. # get login token
  11. r1 = session.get(api_url, params={
  12.     'format': 'json',
  13.     'action': 'query',
  14.     'meta': 'tokens',
  15.     'type': 'login',
  16. })
  17. #r1.raise_for_status()
  18. print(r1.json())
  19. # log in
  20. r2 = session.post(api_url, data={
  21.     'format': 'json',
  22.     'action': 'login',
  23.     'lgname': username,
  24.     'lgpassword': password,
  25.     'lgtoken': r1.json()['mquery']['tokens']['logintoken'],
  26. })
  27. if r2.json()['login']['result'] != 'Success':
  28.     raise RuntimeError(r2.json())
  29. exit();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top