-
Notifications
You must be signed in to change notification settings - Fork 0
/
quickstart.py
56 lines (45 loc) · 1.81 KB
/
quickstart.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import time
from tempfile import gettempdir
from selenium.common.exceptions import NoSuchElementException
from instapy import InstaPy
insta_username = 'foodofcoincydence'
insta_password = '04281001'
# set headless_browser=True if you want to run InstaPy on a server
# set these in instapy/settings.py if you're locating the
# library in the /usr/lib/pythonX.X/ directory:
# Settings.database_location = '/path/to/instapy.db'
# Settings.chromedriver_location = '/path/to/chromedriver'
session = InstaPy(username=insta_username,
password=insta_password,
headless_browser=False,
multi_logs=True)
try:
session.login()
# settings
session.set_relationship_bounds(enabled=True,
potency_ratio=-1.21,
delimit_by_numbers=True,
max_followers=4590,
max_following=5555,
min_followers=200,
min_following=77)
session.set_do_comment(True, percentage=100)
session.set_comments(['aMEIzing! Great food!', 'So yummm!! Please be our friends!', 'Nicey! Cute pic!!'])
#session.set_dont_include(['friend1', 'friend2', 'friend3'])
#session.set_dont_like(['pizza', 'girl'])
# actions
session.like_by_tags(['cake'], amount=3)
except Exception as exc:
# if changes to IG layout, upload the file to help us locate the change
if isinstance(exc, NoSuchElementException):
file_path = os.path.join(gettempdir(), '{}.html'.format(time.strftime('%Y%m%d-%H%M%S')))
with open(file_path, 'wb') as fp:
fp.write(session.browser.page_source.encode('utf8'))
print('{0}\nIf raising an issue, please also upload the file located at:\n{1}\n{0}'.format(
'*' * 70, file_path))
# full stacktrace when raising Github issue
raise
finally:
# end the bot session
session.end()