41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
import requests, re, json
|
|
|
|
def load_cookies_from_file(file_path):
|
|
with open(file_path, 'r') as file:
|
|
cookies_data = json.load(file)
|
|
|
|
cookies_dict = {}
|
|
|
|
for cookie_data in cookies_data:
|
|
name_raw = cookie_data.get("Name raw", "")
|
|
content_raw = cookie_data.get("Content raw", "")
|
|
cookie_value = f"{content_raw}"
|
|
|
|
if len(cookie_value) > 0:
|
|
cookies_dict[name_raw] = cookie_value
|
|
|
|
return cookies_dict
|
|
|
|
|
|
if __name__ == '__main__':
|
|
target_url = 'https://fr.aliexpress.com/item/1005005769229528.html'
|
|
|
|
|
|
session = requests.Session()
|
|
cookies_file_path = './cookies.json'
|
|
cookies = load_cookies_from_file(cookies_file_path)
|
|
session.cookies.update(cookies)
|
|
url = 'https://fr.aliexpress.com/item/1005005769229528.html'
|
|
target_page_response = session.get(url)
|
|
|
|
|
|
|
|
if target_page_response.status_code == 200:
|
|
regex = re.compile(r'\"skuActivityAmountLocal\":\"[0-9]*,[0-9]{2}')
|
|
content = re.findall(regex, target_page_response.text)
|
|
print(content)
|
|
else:
|
|
print(f'Failed to fetch target page. Status code: {target_page_response.status_code}')
|
|
|
|
|