Skip to content

Commit

Permalink
Fix login issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Bitwise-01 committed Jul 2, 2020
1 parent 42bc6e0 commit cf95c42
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
database
__pycache__
__pycache__
.vscode
env_insta
25 changes: 14 additions & 11 deletions lib/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from time import time
from requests import Session
from datetime import datetime
from random import choice, randint
from .const import browser_data, response_codes, fetch_time, user_agents, debug

Expand Down Expand Up @@ -33,27 +34,29 @@ def br(self):
return session

def get_token(self):
token = None
try:
token = self.browser.get(
return self.browser.get(
browser_data['home_url'], timeout=fetch_time).cookies.get_dict()['csrftoken']
except:
pass
finally:
return token

def post_data(self):
response = None
data = {browser_data['username_field']: self.username,
browser_data['password_field']: self.password}
enc_password = '#PWD_INSTAGRAM_BROWSER:0:{}:{}'.format(
int(datetime.now().timestamp()), self.password)

data = {
browser_data['username_field']: self.username,
browser_data['password_field']: enc_password
}

try:
response = self.browser.post(
browser_data['login_url'], data=data, timeout=fetch_time).json()
return self.browser.post(
browser_data['login_url'],
data=data,
timeout=fetch_time
).json()
except:
pass
finally:
return response

def check_exists(self, response):
if 'user' in response:
Expand Down
2 changes: 1 addition & 1 deletion lib/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
}

username_field = 'username'
password_field = 'password'
password_field = 'enc_password'
home_url = 'https://www.instagram.com/'
login_url = 'https://www.instagram.com/accounts/login/ajax/'

Expand Down
2 changes: 1 addition & 1 deletion lib/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ def country(self):
@property
def addr(self):
addr = '{}:{}'.format(self.proxy['ip'], self.proxy['port'])
return {'http': addr, 'https': addr}
return {'http': f'http://{addr}', 'https': f'http://{addr}'}

0 comments on commit cf95c42

Please sign in to comment.