cookies
This commit is contained in:
38
send_cookie.py
Normal file
38
send_cookie.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import browser_cookie3
|
||||
import requests
|
||||
import json
|
||||
|
||||
def send_tcg_cookies(api_url: str, browser_type='brave'):
|
||||
"""Get TCGPlayer cookies and send them to the API"""
|
||||
try:
|
||||
# Get cookies from browser
|
||||
cookie_getter = getattr(browser_cookie3, browser_type)
|
||||
cookie_jar = cookie_getter(domain_name='tcgplayer.com')
|
||||
|
||||
# Filter essential cookies
|
||||
cookies = {}
|
||||
for cookie in cookie_jar:
|
||||
if any(key in cookie.name.lower() for key in ['.aspnet', 'tcg', 'session']):
|
||||
cookies[cookie.name] = cookie.value
|
||||
|
||||
# Send to API
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.post(
|
||||
f"{api_url}",
|
||||
headers=headers,
|
||||
json={'cookies': cookies}
|
||||
)
|
||||
|
||||
response.raise_for_status()
|
||||
print("Cookies updated successfully!")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error updating cookies: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
API_URL = "http://192.168.1.41:8000/api/cookies" # Update with your API URL
|
||||
|
||||
send_tcg_cookies(API_URL)
|
Reference in New Issue
Block a user