Я новичок здесь и новичок в программировании. Я пытаюсь войти в систему URL = 'https://www.esselunga.it/area-utenti/applicationCheck?AppName=esselungaEcommerce&daru=https%3A%2F%2Fwww.esselungaacasa.it%3A443%2Fecommerce%2Fnav%2Fauth%2Fsupermercato%2Fhome.html%3F&loginType=light'.
Когда я проверяю веб-страницу, я ясно вижу csrf_token в HTML ('name' = 'X-CSRF-TOKEN') и его значение; однако , когда я извлекаю его с BeautifulSoup, он недоступен. Я проверил содержимое (ques.session (). Get (url) .content) строки csrf_token исчезли , то же самое в «Просмотр источника страницы».
Можно ли получить CSRF все еще, или есть в любом случае войти без него?
спасибо!
import requests
from bs4 import BeautifulSoup
## Here below the data collected from the Network source view, once i logged in. Form Data section:
login_data= {'username':'xxxx', # <- instead of xxx put your username
'password':'xxxx', # <- instead of xxx put your psswrd
'daru':'xxx', # <- data taken from the FORM DATA
'dare':'xxxx', # <- data taken from the FORM DATA
'appName': 'xxx'} # <- data taken from the FORM DATA
with requests.Session() as s:
login_url="xxx" #<- the URL is above in the comment
result = s.get(login_url)
print (result.content) # here you can see the X-CSRF-TOKEN is not extracted.
soup = BeautifulSoup(result.content,'html5lib')
p = soup.find('input', attrs={'name':'X-CSRF-TOKEN'})['value'] # I can see it in the inspection tab
print(p) # csrf token is not in the content, neither when i check the 'view page source'. But in the inspection I see it!
## I am stuck at the above line. The following would be:
login_data['X-CSRF-TOKEN']) = p
r = s.post(login_url,data=login_data)
print(r.content)