I am trying to login to instagram.Here is my code
from bs4 import BeautifulSoup
from requests import *
payload = {
'action': 'login',
'username': 'name',
'password': 'pass'
}
with session() as c:
c.post('https://www.instagram.com/login.php', data=payload)
response = c.get('https://www.instagram.com/accounts/edit/')
print(response.headers)
print(response.text)
unfortunately it doesn't seem to log me in. I get:
lt-ie8 lt-ie7 not-logged-in client-root
Any solutions would be much appreciated. Thanks.
you can get idea to implement this from here
Logging to Instagram using Python requests
my code for login to instagram
import pdb
from selenium import webdriver
driver = webdriver.PhantomJS()
driver.get('https://www.instagram.com/accounts/login/')
dom = driver.find_element_by_xpath('//*')
pdb.set_trace()
username = dom.find_element_by_name('username')
password = dom.find_element_by_name('password')
login_button = dom.find_element_by_xpath('//*[@class="_qv64e _gexxb _4tgw8 _njrw0"]')
username.clear()
password.clear()
username.send_keys('your username')
password.send_keys('your password')
login_button.click()
driver.get('https://www.instagram.com/accounts/login')
if 'logged-in' in driver.page_source:
print 'Logged in'
您需要一个 API 密钥才能调用 Instagram API,而且我认为您不能直接登录这样的人。
我建议您使用Selenium和PhantomJS webdriver 。
Thanks all for the help. I decided to use selenium insinstead
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.