Created
June 17, 2024 14:11
-
-
Save jalotra/8d2c26f8df6c55fa280cdf2ec45b62b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
addresses = [{ | |
"street_name": "Sarjapur Road", | |
"address_detail": "Silver Spring", | |
"postal_code": "560035", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "MG Road", | |
"address_detail": "Brigade Road Junction", | |
"postal_code": "560001", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Indiranagar", | |
"address_detail": "100 Feet Road", | |
"postal_code": "560038", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Whitefield", | |
"address_detail": "ITPL Main Road", | |
"postal_code": "560066", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Koramangala", | |
"address_detail": "80 Feet Road", | |
"postal_code": "560034", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Electronic City", | |
"address_detail": "Hosur Road", | |
"postal_code": "560100", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Jayanagar", | |
"address_detail": "4th Block", | |
"postal_code": "560041", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Richmond Road", | |
"address_detail": "Richmond Town", | |
"postal_code": "560025", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Bannerghatta Road", | |
"address_detail": "Bilekahalli", | |
"postal_code": "560076", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Banaswadi", | |
"address_detail": "Outer Ring Road", | |
"postal_code": "560043", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Malleshwaram", | |
"address_detail": "15th Cross", | |
"postal_code": "560003", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Hebbal", | |
"address_detail": "Bellary Road", | |
"postal_code": "560024", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Yeshwanthpur", | |
"address_detail": "Tumkur Road", | |
"postal_code": "560022", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Vijayanagar", | |
"address_detail": "Mysore Road", | |
"postal_code": "560040", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Kalyan Nagar", | |
"address_detail": "Kammanahalli Main Road", | |
"postal_code": "560043", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "HSR Layout", | |
"address_detail": "27th Main Road", | |
"postal_code": "560102", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Ulsoor", | |
"address_detail": "Halasuru", | |
"postal_code": "560008", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "Frazer Town", | |
"address_detail": "Coles Road", | |
"postal_code": "560005", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "JP Nagar", | |
"address_detail": "Kanakapura Road", | |
"postal_code": "560078", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
}, | |
{ | |
"street_name": "BTM Layout", | |
"address_detail": "11th Main Road", | |
"postal_code": "560076", | |
"city": "Bengaluru", | |
"region": "KA", | |
"country": "IN" | |
} | |
] | |
def call_d_o(street_name : str, address_detail : str, postal_code : str, city : str, region : str, country : str): | |
url = "https://cloud.digitalocean.com/graphql" | |
payload = json.dumps({ | |
"operationName": "calculateTaxV2", | |
"variables": { | |
"CalculateTaxRequest": { | |
"street_name": street_name, | |
"address_detail": address_detail, | |
"postal_code": postal_code, | |
"city": city, | |
"region": region, | |
"country": country | |
} | |
}, | |
"query": "mutation calculateTaxV2($CalculateTaxRequest: CalculateTaxRequest) {\n calculateTaxV2(CalculateTaxRequest: $CalculateTaxRequest) {\n found_address\n invoice_address {\n street_name\n address_detail\n postal_code\n city\n state\n __typename\n }\n storage_required_fields\n tax_required_fields\n detected_country\n error {\n status\n error_code\n messages\n __typename\n }\n __typename\n }\n}\n" | |
}) | |
headers = { | |
'accept': '*/*', | |
'accept-language': 'en-IN,en-GB;q=0.9,en-US;q=0.8,en;q=0.7', | |
'apollographql-client-name': 'mod-account-settings', | |
'apollographql-client-version': '8b2e1a322143b08e02978e3add7ad065af39f1e6', | |
'baggage': 'sentry-environment=production,sentry-release=8b2e1a322143b08e02978e3add7ad065af39f1e6,sentry-public_key=5fbea5ce7f2e4137bab6a7cd40ac4108,sentry-trace_id=b2ef9f7de5c0444eaf75bfbec22e992f', | |
'content-type': 'application/json', | |
'dnt': '1', | |
'origin': 'https://cloud.digitalocean.com', | |
'priority': 'u=1, i', | |
'referer': 'https://cloud.digitalocean.com/welcome?i=f916bc', | |
'sec-ch-ua': '"Google Chrome";v="125", "Chromium";v="125", "Not.A/Brand";v="24"', | |
'sec-ch-ua-mobile': '?1', | |
'sec-ch-ua-platform': '"Android"', | |
'sec-fetch-dest': 'empty', | |
'sec-fetch-mode': 'cors', | |
'sec-fetch-site': 'same-origin', | |
'sentry-trace': 'b2ef9f7de5c0444eaf75bfbec22e992f-8031cdf820325f23', | |
'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Mobile Safari/537.36', | |
'x-context-id': '4ac0d03b-a915-45f9-ad7b-2690066487ff', | |
'x-context-urn': 'do:user:4ac0d03b-a915-45f9-ad7b-2690066487ff' | |
} | |
return requests.post( | |
url=url, | |
headers=headers, | |
data=payload | |
).json() | |
if __name__ == "__main__": | |
for address in addresses: | |
resp = call_d_o( | |
street_name=address.get("street_name"), | |
address_detail=address.get("address_detail"), | |
postal_code=address.get("postal_code"), | |
city=address.get("city"), | |
region=address.get("region"), | |
country=address.get("country") | |
) | |
if resp.get("data").get("calculateTaxV2").get("found_address"): | |
print(address) | |
exit(1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment