Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Read json File
- with open('profileMulti.json', 'r', encoding='UTF-8') as json_data:
- profiles_string = json.load(json_data)
- def get_individual_profiles(config):
- top_layer = config.get('Profiles')
- if top_layer:
- top_level_keys = ['profile_{}'.format(i) for i in range(len(top_layer))]
- print(top_level_keys)
- return [(key, top_layer.get(key)) for key in top_level_keys]
- return []
- def stringify(key, next_layer):
- return [
- ' '.join(key.capitalize().split('_')),
- next_layer.get('Name'),
- next_layer.get('Last_Name'),
- next_layer.get('Email'),
- next_layer.get('Phone')
- #etc etc...
- ]
- config = profiles_string
- profiles = get_individual_profiles(config)
- pool = ThreadPool()
- # Launch a process for each item
- threads = [pool.apply_async(stringify, tuple(item)) for item in profiles]
- # get() the results as each finishes
- results = [res.get() for res in threads]
- print('threaded results:')
- for item in results:
- print(item)
- threaded results:
- ['Profile 0', 'Thrill', 'Ofit', 'Stack@hotmail.com', '123 412 123']
- ['Profile 1', 'Hellow', 'World', 'Stac321k@hotmail.com', '543 412 312']
- def checkoutNames(NameUrl, nameID):
- payload = {
- "shared": {
- "challenge": {
- "Name": item["Name"],
- "Last_Name": item["Last_Name"],
- "Email": item["Email"],
- "Phone": item["Phone"],
- print(item[1])
- {
- "Profiles": {
- "profile_0": {
- "Url": "Myownwebsite.se",
- "My-Note": "Helloworld",
- "Email": "Stackoverflow@gmail.com"
- "PersonNumber": "1234543",
- "postal_code": "54123",
- "given_name": "World",
- "Last_name": "Hellow",
- "street_address": "helloworld 123",
- "city": "Stockholm",
- "country": "Sweden",
- "phone": "123456789",
- "Color": "Red",
- "house_number": "123",
- "year": "2017"
- },
- "profile_1": {
- "Url": "Myasdwfaesite.se",
- "My-Note": "aasfase",
- "Email": "fasfsef@gmail.com"
- "PersonNumber": "5634543",
- "postal_code": "123445",
- "given_name": "Balling",
- "Last_name": "Calling",
- "street_address": "qwertr 123",
- "city": "London",
- "country": "UK",
- "phone": "65412331",
- "Color": "Blue",
- "house_number": "321",
- "year": "2018"
- }
- #Profile_2 etc etc
- }
- }
- with open('profileMulti.json', 'r', encoding='UTF-8') as json_data:
- config = json.load(json_data)
- NameUrl = config["Url"]
- myNote = config["My-Note"]
- def checkoutNames(NameUrl, nameID):
- #Request & other codes - Removed to recude the code
- #......
- #......
- headers = {
- 'Referer': '',
- 'Content-Type': ''
- }
- payload = {
- "shared": {
- "challenge": {
- "email": config["Email"],
- "PersonNumber": config["PersonNumber"],
- "postal_code": config["ZipCode"],
- "given_name": config["Name"],
- "Last_name": config["LastName"],
- "street_address": config["Address"],
- "postal_code": config["ZipCode"],
- "city": config["City"],
- "country": config["Country"],
- "email": config["Email"],
- "phone": config["Phone"],
- }
- def checkoutNotes(NamesUrl, NamesPost):
- #Request & other codes - Removed to recude the code
- #......
- #......
- headers = {
- 'Accept': 'application/json, text/javascript, /; q=0.01',
- 'Accept-Language': 'en-US,en;q=0.5',
- 'Accept-Encoding': 'gzip, deflate, br',
- 'Referer': NameUrl,
- 'Connection': 'keep-alive'
- }
- payloadInfo = {
- "Information": {
- "Color": config["Color"],
- "house_number": config["houseNumber"],
- "year": config["Year"]
- }
- }
- def wipe():
- os.system('cls' if os.name == 'nt' else 'clear')
- def main():
- time.sleep(1)
- FindName(myNote)
- if _name_ == '_main_':
- try: {
- main()
- }
- except KeyboardInterrupt:
- wipe()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement