Untitled
unknown
python
2 years ago
1.6 kB
2
Indexable
Never
import requests def get_mortgage_rates(amortization, city, downPaymentPercent, homePrice, isCashBack, isOpen, isOwnerOccupied, isPreApproval, language, province, term, type): url = 'https://api.ratehub.ca/mortgage-rates/all/purchase-rates' headers = { 'authority': 'api.ratehub.ca', 'accept': '*/*', 'accept-language': 'en-CA,en-US;q=0.9,en-GB;q=0.8,en;q=0.7', 'dnt': '1', 'origin': 'https://www.ratehub.ca', 'referer': 'https://www.ratehub.ca/', 'sec-ch-ua': '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"', 'sec-ch-ua-mobile': '?0', 'sec-ch-ua-platform': '"macOS"', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-site', 'sec-gpc': '1', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36', 'Content-Type': 'application/json' } payload = { 'amortization': amortization, 'city': city, 'downPaymentPercent': downPaymentPercent, 'homePrice': homePrice, 'isCashBack': isCashBack, 'isOpen': isOpen, 'isOwnerOccupied': isOwnerOccupied, 'isPreApproval': isPreApproval, 'language': language, 'province': province, 'term': term, 'type': type } response = requests.get(url, headers=headers, params=payload) return response if __name__ == "__main__": response = get_mortgage_rates(25, 'Oakville', 0.2, 400000, 0, 0, 1, 0, 'en', 'ON', 60, 'fixed') print(response.json())