My code for login:
import re
import requests
from datetime import datetime
link = 'https://www.instagram.com/accounts/login/'
login_url = 'https://www.instagram.com/accounts/login/ajax/'
user_name = ****
password = ****
time = int(datetime.now().timestamp())
print(time)
payload = {
'username': user_name,
'enc_password': f'#PWD_INSTAGRAM_BROWSER:0:{time}:password',
'queryParams': {},
'optIntoOneTap': 'false'
}
with requests.Session() as s:
r = s.get(link)
a = r.cookies['csrftoken']
print(a)
csrf = re.findall(r"csrf_token\":\"(.*?)\"", r.text)[0]
print(csrf)
r = s.post(login_url, data=payload, headers={
"User-Agent": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
"Referer": "https://www.instagram.com/accounts/login/",
"x-csrftoken": csrf
})
print(r.status_code)
print(r.url)
print(r.text)
print(s.cookies)
r = s.get('https://www.instagram.com/accounts/edit/')
print('user_name' in r.text)
How to make a correct photo upload request ? I found one solution, but it's on php... https://m.habr.com/ru/post/486714/
I don't know how to do it right with python
Aucun commentaire:
Enregistrer un commentaire