Created
September 24, 2021 15:59
-
-
Save Hemant27031999/222166f22f4de660e68d91315ac2e665 to your computer and use it in GitHub Desktop.
Hugesnet ISP reverse API
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 | |
from Address import Address | |
import json | |
from urllib.parse import quote | |
from geopy.geocoders import Nominatim | |
def make_request(address): | |
locator = Nominatim(user_agent="myGeocoder") | |
location = locator.geocode(address.fullAddress()) | |
address_split = [x.strip() for x in location.address.split(',')] | |
state_code = [x.strip() for x in address.fullAddress().split(',')][-2] | |
route = address_split[1].replace(' ', '+') | |
country = address_split[-1].replace(' ', '+') | |
other_info = "&form_build_id=form-UCKM0b74_N2FS9v97xTzBDHOo6k_EQDhwE3PA-johoo&form_id=epq_lookup_form" | |
form_data = "autocomplete=" + address_split[6] + \ | |
"&street=" + address_split[0] + \ | |
"&route=" + route + \ | |
"&city=" + address_split[3] + \ | |
"&state=" + state_code + \ | |
"&zip=" + address_split[6] + \ | |
"&country=" + country + \ | |
"&lat=" + str(location.latitude) + \ | |
"&lng=" + str(location.longitude) + \ | |
other_info | |
req_header = { | |
'Host': 'www.hughesnet.com', | |
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0', | |
'Accept': 'application/json, text/javascript, */*; q=0.01', | |
'Accept-Language': 'en-US,en;q=0.5', | |
'Accept-Encoding': 'gzip, deflate, br', | |
'Referer': 'https://www.hughesnet.com/get-started', | |
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', | |
'X-Requested-With': 'XMLHttpRequest', | |
'Content-Length': '268', | |
'Origin': 'https://www.hughesnet.com', | |
'DNT': '1', | |
'Connection': 'keep-alive', | |
'TE': 'Trailers' | |
} | |
# form_data = "autocomplete=125+Moss+Ave%2C+Oakland%2C+CA+94611&street=125&route=Moss+Avenue&city=Oakland&state=CA&zip=94611&country=United+States&lat=37.82079840623276&lng=-122.25362099211607&form_build_id=form-UCKM0b74_N2FS9v97xTzBDHOo6k_EQDhwE3PA-johoo&form_id=epq_lookup_form" | |
url = "https://www.hughesnet.com/get-started?ajax_form=1&_wrapper_format=drupal_ajax" | |
response = requests.post(url, data = form_data, headers = req_header) | |
print(json.dumps(response.json(), indent=1)) | |
if __name__ == "__main__": | |
add1 = Address("9 TEMPE WICK RD", "07945", "MENDHAM", "NJ") | |
add2 = Address("125 MOSS AVE", "94611", "OAKLAND", "CA") | |
make_request(add1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment