I was trying to integrate LoqateAPI for phone number validator, i want to validate bulk phones number in txt files
BELLOW IS MY CODE
Is anyone here to help me out please, i didn't suppose to get this type of error
phone_number = (
open(
input(f"\n{bwh}{ble}Enter Phone Number List{res}{gr} [phone.txt]{res} : "), "r"
)
.read()
.splitlines()
)
access_key = input(
f"\n{bwh}{ble}Enter Your LoqateAPI Key {res}{gr} [AA11-AA11-AA11-AA11]{res} : "
)
country_code = input(f"\n{bwh}{ble}Enter Country Code {res}{gr} [US]{res} : ")
print("------------------------------------------------------------------")
for i in phone_number:
url = (
"https://api.addressy.com/PhoneNumberValidation/Interactive/Validate/v2.20/json.ws?&Key="
+ access_key
+ "&Phone="
+ str(i)
+ "&Country="
+ country_code
)
response = requests.get(url)
answer = response.json()
if answer["carrier"]:
print(url)
print(f'{gr}{answer["number"]}{res}{yl} => {cy}{answer["carrier"]}{res}')
save = open(f'Result/{answer["carrier"]}.txt', "a+")
save.write(str(i) + "\n")
else:
print(f'{red}{answer["number"]} => Die{res}')
dk = open("Result/die.txt", "a+")
dk.write(str(i) + "\n")
input("Click Enter For Exit ...!")
This bellow text is my output Below is the problem I'm getting
**
Edited I print out the response from a string
**
But the respond was in a json, what type of json is this please i want to know
[{'PhoneNumber': '+14143392867', 'RequestProcessed': 'True', 'IsValid': 'Yes', 'NetworkCode': '180', 'NetworkName': 'AT&T Wireless', 'NetworkCountry': 'US', 'NationalFormat': '(414) 339-2867', 'CountryPrefix': '1', 'NumberType': 'Mobile'}]
[{'PhoneNumber': '+14146789198', 'RequestProcessed': 'True', 'IsValid': 'Yes', 'NetworkCode': '910', 'NetworkName': 'Google (Grand Central) - SVR', 'NetworkCountry': 'US', 'NationalFormat': '(414) 678-9198', 'CountryPrefix': '1', 'NumberType': 'VOIP'}]
[{'PhoneNumber': '+14148458738', 'RequestProcessed': 'False', 'IsValid': 'Maybe', 'NetworkCode': '', 'NetworkName': '', 'NetworkCountry': 'US', 'NationalFormat': '(414) 845-8738', 'CountryPrefix': '1', 'NumberType': 'Unknown'}]
[{'PhoneNumber': '+14141120704', 'RequestProcessed': 'True', 'IsValid': 'No', 'NetworkCode': '', 'NetworkName': '', 'NetworkCountry': 'US', 'NationalFormat': '(414) 112-0704', 'CountryPrefix': '1', 'NumberType': 'Unknown'}]
[{'PhoneNumber': '+14140646454', 'RequestProcessed': 'True', 'IsValid': 'No', 'NetworkCode': '', 'NetworkName': '', 'NetworkCountry': 'US', 'NationalFormat': '(414) 064-6454', 'CountryPrefix': '1', 'NumberType': 'Unknown'}]
Click Enter For Exit ...!
**I GET IT DONE BY BYPASS OPEN BRACKET "[] IN ARRAY JSON **
Thanks everyone
Someone may need help some days too Here is the link of the threads i follow up
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.