Advertisement
Guest User

Untitled

a guest
Dec 4th, 2017
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.57 KB | None | 0 0
  1. import pymysql.cursors
  2. import grequests
  3. import requests
  4. import json
  5.  
  6. connection = pymysql.connect(host='10.3.0.7',
  7. user='bigfood',
  8. password='ooKeeko8ciMa',
  9. db='bigfood_jabba',
  10. port=3306)
  11.  
  12. try:
  13. with connection.cursor() as cursor:
  14. sql = "INSERT INTO couriers (type, api_key, username, enabled, salt, roles, password," \
  15. " created_at, phone_number, telegram_name) VALUES (%s, %s, %s, %s, %s, %s, %s, now(), %s, %s)"
  16.  
  17. executeparlist = [('pedestrian', '9hpbygz9f8cgccs0c88w4w8wkgossgs', 'T1', 1,
  18. '9dq0sn6fuf40gcgkcsc8sg4ggg4kgco', '[]',
  19. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  20. '+79603075765', 'RayneBloodlines'),
  21. ('pedestrian', '9hpbygz9f8cgccs0c88w4w8wkgossg2', 'T2', 1,
  22. '9dq0sn6fuf40gcgkcsc8sg4ggg4kgco', '[]',
  23. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  24. '+79603075763', 't2'),
  25. ('bicycle', '9hpbygz9f8cgccs0c88w4w8wkgossg3', 'T3', 1,
  26. '9dq0sn6fuf40gcgkcsc8sg4ggg41234', '[]',
  27. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  28. '+79603075761', 't3'),
  29. ('bicycle', '9hpbygz9f8cgccs0c88w4w8wkgossg4', 'T4', 1,
  30. '9dq0sn6fuf40gcgkcsc8sg4ggg4kg22', '[]',
  31. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  32. '+79603075762', 't4'),
  33. ('motorcycle', '9hpbygz9f8cgccs0c88w4w8wkgossg5', 'T5', 1,
  34. '9dq0sn6fuf40gcgkcsc8sg4ggg4kg33', '[]',
  35. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  36. '+79603075764', 't5'),
  37. ('motorcycle', '9hpbygz9f8cgccs0c88w4w8wkgossg6', 'T6', 1,
  38. '9dq0sn6fuf40gcgkcsc8sg4ggg4kg44', '[]',
  39. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  40. '+79603075766', 't6'),
  41. ('vehicle', '9hpbygz9f8cgccs0c88w4w8wkgossg7', 'T7', 1,
  42. '9dq0sn6fuf40gcgkcsc8sg4ggg4kg55', '[]',
  43. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  44. '+79603075767', 't7'),
  45. ('vehicle', '9hpbygz9f8cgccs0c88w4w8wkgossg8', 'T8', 1,
  46. '9dq0sn6fuf40gcgkcsc8sg4ggg4kg66', '[]',
  47. '$2y$08$9EdeeuqI1I2bF3B01UahSOFcVXrJQSWpfqr5bkJC40YdZGs9VUriC',
  48. '+79603075768', 't8')]
  49. for item in executeparlist:
  50. cursor.execute(sql, item)
  51. connection.commit()
  52.  
  53.  
  54. with connection.cursor() as cursor:
  55. sql = "UPDATE couriers SET location_date = '2018-12-30 16:59:52'" \
  56. "where username in ('T1','T2','T3','T4','T5','T6','T7','T8')"
  57. cursor.execute(sql)
  58. connection.commit()
  59.  
  60. with connection.cursor() as cursor:
  61. sql = "UPDATE couriers SET location_latitude = %s, location_longitude = %s where username = %s;"
  62.  
  63. executeloclist = [('55.775365', '37.468980', 'T1'),
  64. ('55.706658', '37.658636', 'T2'),
  65. ('55.759195', '37.643371', 'T3'),
  66. ('55.759177', '37.609677', 'T4'),
  67. ('55.730480', '37.592104', 'T5'),
  68. ('55.727793', '37.474156', 'T6'),
  69. ('55.758664', '37.618171', 'T7'),
  70. ('55.701256', '37.497081', 'T8')]
  71. for item in executeloclist:
  72. cursor.execute(sql, item)
  73. connection.commit()
  74.  
  75.  
  76.  
  77. url_cart = 'https://jabba.foodfox.ru/api/v1/cart'
  78. payload_cart_Ktown = {
  79. "item_id": 209670
  80. }
  81. payload_cart_nana = {
  82. "item_id": 211
  83. }
  84.  
  85. url_order = 'https://jabba.foodfox.ru/api/v1/orders/unauthorized'
  86. payload_order_Ktown = {
  87. "payment_method_id": "0",
  88. "phone": "9603255444",
  89. "without_callback": "false",
  90. "email": "test@tt.tdtd",
  91. "first_name": "test",
  92.  
  93. "address": {
  94. "city": "Москва",
  95. "street": "Пыжевский пер",
  96. "house": "5с2"
  97. },
  98. "location": {
  99. "latitude": "55.738904",
  100. "longitude": "37.623066"
  101. }
  102. }
  103.  
  104. payload_order_nana = {
  105. "payment_method_id": "0",
  106. "phone": "9603255444",
  107. "without_callback": "false",
  108. "email": "test@tt.tdtd",
  109. "first_name": "test",
  110.  
  111. "address": {
  112. "city": "Москва",
  113. "street": "ул. Новокузнецкар",
  114. "house": "16"
  115. },
  116. "location": {
  117. "latitude": "55,740679",
  118. "longitude": "37,637093"
  119. }
  120. }
  121.  
  122. headers = {'Content-Type': 'application/json'}
  123. ck = requests.post(url_cart, data=json.dumps(payload_cart_Ktown))
  124. ok = requests.post(url_order, headers=headers, cookies=ck.cookies, data=json.dumps(payload_order_Ktown))
  125. #print(ok.json())
  126. logout = grequests.post('https://jabba.foodfox.ru/api/v1/user/logout')
  127.  
  128. cn = requests.post(url_cart, data=json.dumps(payload_cart_nana))
  129. on = requests.post(url_order, headers=headers, cookies=cn.cookies, data=json.dumps(payload_order_nana))
  130. #print(on.json())
  131.  
  132.  
  133.  
  134. finally:
  135. connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement