cookies directly from tag.js not work
This commit is contained in:
@@ -1,7 +1,51 @@
|
||||
import random
|
||||
from http.cookies import SimpleCookie
|
||||
import requests
|
||||
|
||||
from models.LinkPojo import LinkPojo
|
||||
from workers.proxies_constants import PROXY_LIST
|
||||
|
||||
|
||||
class LinkValidator:
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self, cookie_str, link_to_validate: LinkPojo):
|
||||
self.cookie = SimpleCookie()
|
||||
self.link = link_to_validate.url
|
||||
# self.cookie_str = 'datadome=~pxdHFAvsQl2rvDrTzhPgCHxu~4TBcePTTE~Cy8Rgol6oMRc11gA02VRp0Z3uEDUszCjacubNu7vbfQCh27gz8RC10u_325pt_gsMmJh1ScGvOofVJiVAbEKvSEUjd82;policy=accepted;app.sig=PhjmDkq_dI49pADppDNKxpLe_G4;app=eyJmbGFzaCI6e30sImNhY2hlZmxhc2giOltdLCJjc3JmU2VjcmV0IjoiYnRodHNYU1lvdnl4RzVGakpGRDZsQ0JtIn0=;lang=fr;'
|
||||
self.cookie_str = cookie_str
|
||||
self.cookie.load(self.cookie_str)
|
||||
|
||||
def send_request(self, link):
|
||||
pass
|
||||
def send_request(self):
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Mobile Safari/537.36',
|
||||
'Accept': '*/*',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Cache-Control': 'max-age=0',
|
||||
'Referer': self.link,
|
||||
'Cookie': self.cookie_str,
|
||||
'Sec-Fetch-Mode': 'navigate',
|
||||
'Host': 'rendezvousparis.hermes.com',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'Sec-Fetch-Dest': 'document',
|
||||
'Accept-Language': 'fr-FR,fr;q=0.6'}
|
||||
proxy_to_use = random.choice(PROXY_LIST)
|
||||
print(proxy_to_use)
|
||||
print("received cookie is " + str(self.cookie_str))
|
||||
try:
|
||||
response = requests.get(url=self.link, headers=headers, verify=False, proxies=proxy_to_use,
|
||||
timeout=15)
|
||||
print(response.status_code)
|
||||
if response.status_code == 200:
|
||||
print(response.text)
|
||||
print(response.url)
|
||||
else:
|
||||
return None
|
||||
except Exception as error:
|
||||
print(error)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
link_validator = LinkValidator(
|
||||
cookie_str="W3BqZ5LSU5~Yl1LAd68HLGCuSELSQzuyPC1xuM0MpMLwX13p0HxwYL4mxM6BgmtLe0TwMyJKRnOdZgMW2CzGW0h53oQDNioqXAt0GbiDbiY5R_AaUajk_O7MtDqPwFCB;policy=accepted;app.sig=C3MpoPl8yFlKfm6UIrgnxYqs8Hs;app=eyJmbGFzaCI6e30sImNhY2hlZmxhc2giOltdLCJjc3JmU2VjcmV0IjoiV3Z6QWJGX09jZXpQREFnZW9PcnM4eXNIIn0=;lang=fr;",
|
||||
link_to_validate="https://rendezvousparis.hermes.com/client/register/55TCMY/validate?code=011367")
|
||||
link_validator.send_request()
|
||||
|
||||
Reference in New Issue
Block a user