Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. import requests
  2.  
  3. if __name__ == "__main__":
  4. URL = 'http://news-admin.ngenics.ai/admin/login/?next=/admin/'
  5.  
  6. client = requests.session()
  7. client.get(URL) # sets cookie
  8. token = client.cookies['csrftoken']
  9.  
  10. login_data = dict(username='admin',
  11. password='ExoPRVpaUhfZ$]6Cmza7ee',
  12. csrfmiddlewaretoken=token,
  13. next='/admin/')
  14. r = client.post(URL, data=login_data, headers=dict(Referer=URL))
  15.  
  16. URL_Pers = 'http://news-admin.ngenics.ai/admin/public/person/add/'
  17. client.get(URL_Pers) # sets cookie
  18. token = client.cookies['csrftoken']
  19.  
  20. person_data = {
  21. 'csrfmiddlewaretoken': token,
  22. 'surname_ru' : 'Зубко',
  23. 'first_name_ru' : 'Геннадий',
  24. 'surname_uk' : 'Зубко',
  25. 'first_name_uk' : 'Генадій',
  26. 'family_name_ru' : '',
  27. 'family_name_uk' : '',
  28. 'country_of_birth' : '',
  29. 'date_of_birth' : '',
  30. 'date_of_death' : '',
  31. 'official_position' : '',
  32. 'wiki_link' : '',
  33. 'description' : '',
  34. 'vkontakte_link' : '',
  35. 'facebook_link' : '',
  36. 'twitter_link' : '',
  37. 'livejournal_link' : '',
  38. 'youtube_link' : '',
  39. 'instagram_link' : '',
  40. 'is_active' : '',
  41. 'images-TOTAL_FORMS' : '',
  42. 'images-INITIAL_FORMS' : '',
  43. 'images-MIN_NUM_FORMS' : '',
  44. 'images-MAX_NUM_FORMS' : '',
  45. 'images-0-id' : '',
  46. 'images-0-person' : '',
  47. 'images-0-images' : '',
  48. 'images-1-id' : '',
  49. 'images-1-person' : '',
  50. 'images-1-images' : '',
  51. 'images-2-id' : '',
  52. 'images-2-person' : '',
  53. 'images-2-images' : '',
  54. 'images-__prefix__-id' : '',
  55. 'images-__prefix__-person' : '',
  56. 'images-__prefix__-images' : '',
  57. 'category-TOTAL_FORMS' : '',
  58. 'category-INITIAL_FORMS' : '',
  59. 'category-MIN_NUM_FORMS' : '',
  60. 'category-MAX_NUM_FORMS' : '',
  61. 'category-0-id' : '',
  62. 'category-0-person' : '',
  63. 'category-0-category' : '',
  64. 'category-1-id' : '',
  65. 'category-1-person' : '',
  66. 'category-1-category' : '',
  67. 'category-2-id' : '',
  68. 'category-2-person' : '',
  69. 'category-2-category' : '',
  70. 'category-__prefix__-id' : '',
  71. 'category-__prefix__-person' : '',
  72. 'category-__prefix__-category' : '',
  73. '_save' : ''
  74. }
  75.  
  76. r = client.post(URL_Pers, data=person_data, headers=dict(Referer=URL_Pers))
  77.  
  78. file = open("out.html", "w")
  79. file.write(r.text)
  80. file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement