Advertisement
Didicodes

Untitled

Sep 29th, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. import requests
  2.  
  3. url = "http://localhost/wiki/mw-core/api.php"
  4.  
  5. #Use a session insteadfor persistence
  6.  
  7. session = requests.Session()
  8. results = session.get(url, params = {
  9.   'format': 'json',
  10.   'action': 'query',
  11.   'meta': 'tokens',
  12.   'type': 'createaccount'
  13. })
  14.  
  15. print(results.json()['query']['tokens']['createaccounttoken'].encode("utf-8"))
  16.  
  17. token = results.json()['query']['tokens']['createaccounttoken'].encode("utf-8")
  18.  
  19. querystring = {
  20.   "action": "createaccount",
  21.   "createreturnurl": "http://localhost",
  22.   "username": "ucheamaka",
  23.   "email": "ucheamaka@example.com",
  24.   "format": "json"
  25. }
  26.  
  27. payload = {
  28.   "createtoken": token,
  29.   "password": "IlovePython",
  30.   "retype": "IlovePython"
  31. }
  32.  
  33. response = session.post(url, data = payload, params = querystring)
  34.  
  35. print(response.text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement