Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Login to instagram using python

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.

like image 230
Kolya Pavlenko Avatar asked Oct 19 '17 22:10

Kolya Pavlenko


People also ask

Is there an Instagram API for Python?

You can now schedule your instagram posts programmatically without relying on limiting and expensive apps like Hootsuite and Later. You can create your own code to post to instagram up to 25 posts a day using the Instagram Graph API.

How do I get Instagram messages through Python?

To send Instagram message using Python, you need to have an Instagram account and the instabot library installed in your Python virtual environment. Instabot is a Python library that you can use to automate features of your Instagram account using Python, like sending messages without even opening your application.


1 Answers

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'
like image 137
Argus Malware Avatar answered Oct 11 '22 11:10

Argus Malware