Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. #Read json File
  2. with open('profileMulti.json', 'r', encoding='UTF-8') as json_data:
  3. profiles_string = json.load(json_data)
  4.  
  5. def get_individual_profiles(config):
  6. top_layer = config.get('Profiles')
  7. if top_layer:
  8. top_level_keys = ['profile_{}'.format(i) for i in range(len(top_layer))]
  9. print(top_level_keys)
  10. return [(key, top_layer.get(key)) for key in top_level_keys]
  11. return []
  12.  
  13. def stringify(key, next_layer):
  14. return [
  15. ' '.join(key.capitalize().split('_')),
  16. next_layer.get('Name'),
  17. next_layer.get('Last_Name'),
  18. next_layer.get('Email'),
  19. next_layer.get('Phone')
  20. #etc etc...
  21. ]
  22.  
  23. config = profiles_string
  24. profiles = get_individual_profiles(config)
  25.  
  26. pool = ThreadPool()
  27.  
  28. # Launch a process for each item
  29. threads = [pool.apply_async(stringify, tuple(item)) for item in profiles]
  30.  
  31.  
  32. # get() the results as each finishes
  33. results = [res.get() for res in threads]
  34. print('threaded results:')
  35. for item in results:
  36. print(item)
  37.  
  38. threaded results:
  39. ['Profile 0', 'Thrill', 'Ofit', 'Stack@hotmail.com', '123 412 123']
  40.  
  41. ['Profile 1', 'Hellow', 'World', 'Stac321k@hotmail.com', '543 412 312']
  42.  
  43. def checkoutNames(NameUrl, nameID):
  44. payload = {
  45. "shared": {
  46. "challenge": {
  47. "Name": item["Name"],
  48. "Last_Name": item["Last_Name"],
  49. "Email": item["Email"],
  50. "Phone": item["Phone"],
  51.  
  52. print(item[1])
  53.  
  54. {
  55. "Profiles": {
  56. "profile_0": {
  57. "Url": "Myownwebsite.se",
  58. "My-Note": "Helloworld",
  59. "Email": "Stackoverflow@gmail.com"
  60. "PersonNumber": "1234543",
  61. "postal_code": "54123",
  62. "given_name": "World",
  63. "Last_name": "Hellow",
  64. "street_address": "helloworld 123",
  65. "city": "Stockholm",
  66. "country": "Sweden",
  67. "phone": "123456789",
  68. "Color": "Red",
  69. "house_number": "123",
  70. "year": "2017"
  71. },
  72. "profile_1": {
  73. "Url": "Myasdwfaesite.se",
  74. "My-Note": "aasfase",
  75. "Email": "fasfsef@gmail.com"
  76. "PersonNumber": "5634543",
  77. "postal_code": "123445",
  78. "given_name": "Balling",
  79. "Last_name": "Calling",
  80. "street_address": "qwertr 123",
  81. "city": "London",
  82. "country": "UK",
  83. "phone": "65412331",
  84. "Color": "Blue",
  85. "house_number": "321",
  86. "year": "2018"
  87. }
  88.  
  89. #Profile_2 etc etc
  90. }
  91. }
  92.  
  93. with open('profileMulti.json', 'r', encoding='UTF-8') as json_data:
  94. config = json.load(json_data)
  95.  
  96. NameUrl = config["Url"]
  97.  
  98. myNote = config["My-Note"]
  99.  
  100. def checkoutNames(NameUrl, nameID):
  101.  
  102. #Request & other codes - Removed to recude the code
  103. #......
  104. #......
  105. headers = {
  106. 'Referer': '',
  107. 'Content-Type': ''
  108. }
  109. payload = {
  110. "shared": {
  111. "challenge": {
  112. "email": config["Email"],
  113. "PersonNumber": config["PersonNumber"],
  114. "postal_code": config["ZipCode"],
  115. "given_name": config["Name"],
  116. "Last_name": config["LastName"],
  117. "street_address": config["Address"],
  118. "postal_code": config["ZipCode"],
  119. "city": config["City"],
  120. "country": config["Country"],
  121. "email": config["Email"],
  122. "phone": config["Phone"],
  123. }
  124.  
  125. def checkoutNotes(NamesUrl, NamesPost):
  126.  
  127. #Request & other codes - Removed to recude the code
  128. #......
  129. #......
  130.  
  131. headers = {
  132. 'Accept': 'application/json, text/javascript, /; q=0.01',
  133. 'Accept-Language': 'en-US,en;q=0.5',
  134. 'Accept-Encoding': 'gzip, deflate, br',
  135. 'Referer': NameUrl,
  136. 'Connection': 'keep-alive'
  137. }
  138. payloadInfo = {
  139. "Information": {
  140. "Color": config["Color"],
  141. "house_number": config["houseNumber"],
  142. "year": config["Year"]
  143. }
  144. }
  145. def wipe():
  146. os.system('cls' if os.name == 'nt' else 'clear')
  147.  
  148. def main():
  149. time.sleep(1)
  150.  
  151. FindName(myNote)
  152.  
  153. if _name_ == '_main_':
  154. try: {
  155. main()
  156. }
  157. except KeyboardInterrupt:
  158. wipe()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement