Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- import base64
- from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
- from cryptography.hazmat.primitives.hashes import SHA256
- from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
- from cryptography.hazmat.backends import default_backend
- headers = {
- 'authority': 'www.oddsportal.com',
- 'method': 'GET',
- 'scheme': 'https',
- 'accept': 'application/json, text/plain, */*',
- 'accept-encoding': 'deflate',
- 'accept-language': 'en-US,en;q=0.9,fi-FI;q=0.8,fi;q=0.7',
- 'content-type': 'application/json',
- 'referer': 'https://www.oddsportal.com/matches/hockey/20240109',
- 'sec-ch-ua-platform': '"Windows"',
- 'sec-fetch-dest': 'empty',
- 'sec-fetch-mode': 'cors',
- 'sec-fetch-site': 'same-origin',
- 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
- 'x-requested-with': 'XMLHttpRequest'
- }
- version_id=1
- sport_id=1
- unique_id='82qTWLi3'
- xhash='yjdca'
- # URL for fetching the data
- url = f'https://www.oddsportal.com/feed/match-event/{version_id}-{sport_id}-{unique_id}-1-2-{xhash}.dat'
- # Send the GET request and retrieve the response text
- response = requests.get(url, headers=headers)
- data = response.text
- # Decode the base64 encoded data
- decoded_data = base64.b64decode(data).decode()
- # Separate the encrypted data and key
- encrypted, key = decoded_data.split(":")
- # Decode the encrypted part and the key
- encrypted_bytes = base64.urlsafe_b64decode(encrypted)
- key_bytes = bytes.fromhex(key)
- # Define the password and salt used for key derivation
- password = b"%RtR8AB&nWsh=AQC+v!=pgAe@dSQG3kQ"
- salt = b"orieC_jQQWRmhkPvR6u2kzXeTube6aYupiOddsPortal"
- # Derive the AES key using PBKDF2 with SHA256
- kdf = PBKDF2HMAC(
- algorithm=SHA256(),
- length=32, # 256 bits
- salt=salt,
- iterations=1000,
- backend=default_backend()
- )
- aes_key = kdf.derive(password)
- # Set up the AES decryption cipher in CBC mode
- cipher = Cipher(
- algorithms.AES(aes_key),
- modes.CBC(key_bytes),
- backend=default_backend()
- )
- decryptor = cipher.decryptor()
- # Decrypt the data
- decrypted_bytes = decryptor.update(encrypted_bytes) + decryptor.finalize()
- # Decode the decrypted bytes into a string
- decrypted_data = decrypted_bytes.decode('utf-8')
- # Find the end of the JSON data
- end_of_json = decrypted_data.rfind('}')
- # If a valid JSON end is found, trim the data to that point
- if end_of_json != -1:
- decrypted_data = decrypted_data[:end_of_json + 1]
- # Parse the decrypted data as JSON
- try:
- parsed_data = json.loads(decrypted_data)
- print(parsed_data)
- except json.JSONDecodeError as e:
- print("Error parsing JSON:", e)
Add Comment
Please, Sign In to add comment