Advertisement
Didicodes

Untitled

Sep 28th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import requests
  4.  
  5. url = 'https://mediawiki.org/w/api.php'
  6.  
  7. # Retrieve login token first
  8.  
  9. PARAMS_0 = {
  10.     'action': 'query',
  11.     'meta': 'tokens',
  12.     'type': 'createaccount',
  13.     'format': 'json',
  14.     }
  15.  
  16. response = requests.request('GET', url, params=PARAMS_0)
  17. DATA = response.json()
  18.  
  19. CREATE_ACCOUNT_TOKEN = DATA['query']['tokens']['createaccounttoken']
  20.  
  21. print CREATE_ACCOUNT_TOKEN
  22.  
  23. params_1 = {
  24.     'action': 'createaccount',
  25.     'createreturnurl': 'http://example.com/',
  26.     'createtoken': CREATE_ACCOUNT_TOKEN,
  27.     'username': 'Bob',
  28.     'password': 'ExamplePassword',
  29.     'retype': 'ExamplePassword',
  30.     'email': 'bob@example.com',
  31.     'realname': 'Robert',
  32.     'format': 'json',
  33.     }
  34.  
  35. response = requests.post('https://www.mediawiki.org/w/api.php',
  36.                          data=params_1)
  37. print response.text
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement