Skip to content

Commit 78ad421

Browse files
authored
Merge pull request InstaPy#6107 from elulcao/minor_fixes
Minor fixes, some delays for browser actions and traces.
2 parents 74abaa8 + 392d148 commit 78ad421

File tree

9 files changed

+115
-184
lines changed

9 files changed

+115
-184
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ _The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66

77

88
## [0.6.15] - UNRELEASED
9-
109
### Added
1110

1211
- Added `verified_only` argument to `get_followers` to return only verified users
12+
- `mandatory_bio_keywords` control before evaluating for mandatory
1313

1414
## [0.6.14] - UNRELEASED
1515

@@ -19,11 +19,15 @@ _The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1919
- Added `apidisplaypurposes about` in `smart_hashtags` and new api token; Python3.5
2020
- Added `interact_user_likers` interacting with the likers from a given user's posts
2121
- Added second `accept_igcookie_dialogue` to handled the second "cookie accept screen" that is not automatically accepted
22+
- Added delays after `update_activity()` in `follow_util.py` and `util.py`
23+
- Added extra trace in `get_followers()`
2224

2325
### Fixed
2426

2527
- Move call to `get_following_status` above `web_address_navigator` inside `get_links_for_username` function
2628
- Fixed the correct URL `displaypurposes.com`, the old `displaypurposes.com` API is deprecated
29+
- Fixed `additional-information.md`, removed extra info for `cron` configuration
30+
- Fixed `actions.md` and `settings.md` for identation
2731

2832
## [0.6.13] - 2020-12-30
2933

docs/actions.md

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,17 @@ accs = ['therock','natgeo']
152152
session.follow_by_list(accs, times=1, sleep_delay=600, interact=False)
153153
```
154154
* You can also **interact** with the followed users by enabling `interact=True` which will use the configuration of `set_user_interact` setting:
155+
155156
```python
156157
session.set_user_interact(amount=4,
157-
percentage=50,
158-
randomize=True,
159-
media='Photo')
160-
session.follow_by_list(followlist=['samantha3', 'larry_ok'], times=2, sleep_delay=600, interact=True)
158+
percentage=50,
159+
randomize=True,
160+
media='Photo')
161+
162+
session.follow_by_list(followlist=['samantha3', 'larry_ok'],
163+
times=2,
164+
sleep_delay=600,
165+
interact=True)
161166
```
162167

163168

@@ -237,10 +242,16 @@ The `follow_likers_per_photo` is how many people to follow per each photo
237242
* You can also **interact** with the followed users by enabling `interact=True` which will use the configuration of `set_user_interact` setting:
238243
```python
239244
session.set_user_interact(amount=2,
240-
percentage=70,
241-
randomize=True,
242-
media='Photo')
243-
session.follow_likers(['user1' , 'user2'], photos_grab_amount = 2, follow_likers_per_photo = 3, randomize=True, sleep_delay=600, interact=True)
245+
percentage=70,
246+
randomize=True,
247+
media='Photo')
248+
249+
session.follow_likers(['user1' , 'user2'],
250+
photos_grab_amount = 2,
251+
follow_likers_per_photo = 3,
252+
randomize=True,
253+
sleep_delay=600,
254+
interact=True)
244255
```
245256

246257

@@ -259,9 +270,9 @@ The `max_pic` will limit number of photos to analyze
259270
* You can also **interact** with the followed users by enabling `interact=True` which will use the configuration of `set_user_interact` setting:
260271
```python
261272
session.set_user_interact(amount=3,
262-
percentage=32,
263-
randomize=True,
264-
media='Video')
273+
percentage=32,
274+
randomize=True,
275+
media='Video')
265276
session.follow_commenters(['user1', 'user2', 'user3'], amount=100, daysold=365, max_pic = 100, sleep_delay=600, interact=True)
266277
```
267278

@@ -612,15 +623,15 @@ session.remove_follow_requests(amount=200, sleep_delay=600)
612623
```python
613624

614625
photo_comments = ['Nice shot! @{}',
615-
'I love your profile! @{}',
616-
'Your feed is an inspiration :thumbsup:',
617-
'Just incredible :open_mouth:',
618-
'What camera did you use @{}?',
619-
'Love your posts @{}',
620-
'Looks awesome @{}',
621-
'Getting inspired by you @{}',
622-
':raised_hands: Yes!',
623-
'I can feel your passion @{} :muscle:']
626+
'I love your profile! @{}',
627+
'Your feed is an inspiration :thumbsup:',
628+
'Just incredible :open_mouth:',
629+
'What camera did you use @{}?',
630+
'Love your posts @{}',
631+
'Looks awesome @{}',
632+
'Getting inspired by you @{}',
633+
':raised_hands: Yes!',
634+
'I can feel your passion @{} :muscle:']
624635

625636
session = InstaPy()
626637

docs/additional-information.md

Lines changed: 2 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ To do this simply pass the `disable_image_load=True` parameter in the InstaPy co
544544
session = InstaPy(username=insta_username,
545545
password=insta_password,
546546
headless_browser=False,
547-
disable_image_load=True,
547+
disable_image_load=True,
548548
multi_logs=True)
549549
```
550550
@@ -568,7 +568,7 @@ To do this simply pass the `split_db=True` parameter in the InstaPy constructor
568568
session = InstaPy(username=insta_username,
569569
password=insta_password,
570570
headless_browser=False,
571-
split_db=True,
571+
split_db=True,
572572
multi_logs=True)
573573
```
574574

@@ -708,7 +708,6 @@ You can use Window's built in Task Scheduler to automate InstaPy, using a variet
708708
9. "Start in" input Instapy install location (Example: C:\Users\USER_NAME\Documents\GitHub\InstaPy\). Click "Next"
709709
10. To finish the process, hit "Finish"
710710

711-
712711
### `cron`
713712
You can add InstaPy to your crontab, so that the script will be executed regularly. This is especially useful for servers, but be sure not to break Instagrams follow and like limits.
714713

@@ -773,124 +772,6 @@ You can use Window's built in Task Scheduler to automate InstaPy, using a variet
773772
9. "Start in" input Instapy install location (Example: C:\Users\USER_NAME\Documents\GitHub\InstaPy\). Click "Next"
774773
10. To finish the process, hit "Finish"
775774

776-
777-
### `cron`
778-
You can add InstaPy to your crontab, so that the script will be executed regularly. This is especially useful for servers, but be sure not to break Instagrams follow and like limits.
779-
780-
```
781-
# Edit or create a crontab
782-
crontab -e
783-
# Add information to execute your InstaPy regularly.
784-
# With cd you navigate to your InstaPy folder, with the part after &&
785-
# you execute your quickstart.py with python. Make sure that those paths match
786-
# your environment.
787-
45 */4 * * * cd /home/user/InstaPy && /usr/bin/python ./quickstart.py
788-
```
789-
790-
791-
### [Schedule](https://github.com/dbader/schedule)
792-
> Schedule is an in-process scheduler for periodic jobs that uses the builder pattern for configuration. Schedule lets you run Python functions periodically at pre-determined intervals using a simple, human-friendly syntax.
793-
794-
```shell
795-
pip install schedule
796-
```
797-
798-
```python
799-
from instapy import InstaPy
800-
from instapy import smart_run
801-
from instapy import set_workspace
802-
import schedule
803-
import time
804-
805-
#your login credentials
806-
insta_username=''
807-
insta_password=''
808-
809-
#path to your workspace
810-
set_workspace(path=None)
811-
812-
def job():
813-
session = InstaPy(username=insta_username, password=insta_password)
814-
with smart_run(session):
815-
session.set_do_comment(enabled=True, percentage=20)
816-
session.set_comments(['Well done!'])
817-
session.set_do_follow(enabled=True, percentage=5, times=2)
818-
session.like_by_tags(['love'], amount=100, media='Photo')
819-
820-
821-
schedule.every().day.at("6:35").do(job)
822-
schedule.every().day.at("16:22").do(job)
823-
824-
while True:
825-
schedule.run_pending()
826-
time.sleep(10)
827-
```
828-
829-
You can use Window's built in Task Scheduler to automate InstaPy, using a variety of trigger types: time, login, computer idles, etc. To schedule a simple daily run of an Instapy script follow the below directions
830-
1. Open [Windows Task Scheduler](https://msdn.microsoft.com/en-us/library/windows/desktop/aa383614(v=vs.85).aspx)
831-
2. Select "Create Basic Task"
832-
3. Fill out "Name" and "Description" as desired, click "Next"
833-
4. On "Trigger" screen select how frequently to run, click "Next" (Frequency can be modified later)
834-
5. On "Daily" screen, hit "Next"
835-
6. "Action Screen" select "Start a program" and then click "Next"
836-
7. "Program/script" enter the path, or browse to select the path to python. ([How to find python path on Windows](https://stackoverflow.com/questions/647515/how-can-i-get-python-path-under-windows))
837-
8. "Add arguments" input the InstaPy script path you wish to run. (Example: C:\Users\USER_NAME\Documents\GitHub\InstaPy\craigquick.py)
838-
9. "Start in" input Instapy install location (Example: C:\Users\USER_NAME\Documents\GitHub\InstaPy\). Click "Next"
839-
10. To finish the process, hit "Finish"
840-
841-
842-
### `cron`
843-
You can add InstaPy to your crontab, so that the script will be executed regularly. This is especially useful for servers, but be sure not to break Instagrams follow and like limits.
844-
845-
```
846-
# Edit or create a crontab
847-
crontab -e
848-
# Add information to execute your InstaPy regularly.
849-
# With cd you navigate to your InstaPy folder, with the part after &&
850-
# you execute your quickstart.py with python. Make sure that those paths match
851-
# your environment.
852-
45 */4 * * * cd /home/user/InstaPy && /usr/bin/python ./quickstart.py
853-
```
854-
855-
856-
### [Schedule](https://github.com/dbader/schedule)
857-
> Schedule is an in-process scheduler for periodic jobs that uses the builder pattern for configuration. Schedule lets you run Python functions periodically at pre-determined intervals using a simple, human-friendly syntax.
858-
859-
```shell
860-
pip install schedule
861-
```
862-
863-
```python
864-
from instapy import InstaPy
865-
from instapy import smart_run
866-
from instapy import set_workspace
867-
import schedule
868-
import time
869-
870-
#your login credentials
871-
insta_username=''
872-
insta_password=''
873-
874-
#path to your workspace
875-
set_workspace(path=None)
876-
877-
def job():
878-
session = InstaPy(username=insta_username, password=insta_password)
879-
with smart_run(session):
880-
session.set_do_comment(enabled=True, percentage=20)
881-
session.set_comments(['Well done!'])
882-
session.set_do_follow(enabled=True, percentage=5, times=2)
883-
session.like_by_tags(['love'], amount=100, media='Photo')
884-
885-
886-
schedule.every().day.at("6:35").do(job)
887-
schedule.every().day.at("16:22").do(job)
888-
889-
while True:
890-
schedule.run_pending()
891-
time.sleep(10)
892-
```
893-
894775
<ins
895776
class="adsbygoogle"
896777
data-ad-layout="in-article"

docs/settings.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,21 @@ session.like_by_tags(amount=10, use_smart_hashtags=True)
128128
###### Take full control of the actions with the most sophisticated approaches
129129

130130
```python
131-
session.set_quota_supervisor(enabled=True, sleep_after=["likes", "comments_d", "follows", "unfollows", "server_calls_h"], sleepyhead=True, stochastic_flow=True, notify_me=True,
132-
peak_likes_hourly=57,
133-
peak_likes_daily=585,
134-
peak_comments_hourly=21,
135-
peak_comments_daily=182,
136-
peak_follows_hourly=48,
137-
peak_follows_daily=None,
138-
peak_unfollows_hourly=35,
139-
peak_unfollows_daily=402,
140-
peak_server_calls_hourly=None,
141-
peak_server_calls_daily=4700)
131+
session.set_quota_supervisor(enabled=True,
132+
sleep_after=["likes", "comments_d", "follows", "unfollows", "server_calls_h"],
133+
sleepyhead=True,
134+
stochastic_flow=True,
135+
notify_me=True,
136+
peak_likes_hourly=57,
137+
peak_likes_daily=585,
138+
peak_comments_hourly=21,
139+
peak_comments_daily=182,
140+
peak_follows_hourly=48,
141+
peak_follows_daily=None,
142+
peak_unfollows_hourly=35,
143+
peak_unfollows_daily=402,
144+
peak_server_calls_hourly=None,
145+
peak_server_calls_daily=4700)
142146
```
143147
#### Parameters:
144148
`enabled`: put `True` to **activate** or `False` to **deactivate** supervising any time
@@ -418,7 +422,7 @@ This will skip all business accounts except the ones that have a category that m
418422
skip_no_profile_pic=True,
419423
skip_business=True,
420424
skip_non_business=True,
421-
dont_skip_business_categories=['Creators & Celebrities'])
425+
dont_skip_business_categories=['Creators & Celebrities'])
422426
```
423427
This will skip all non business and business accounts except categories in _dont_skip_business_categories_.
424428
@@ -504,14 +508,14 @@ session.set_delimit_commenting(enabled=True, comments_mandatory_words=['cat', 'd
504508
##### This is used to check the number of _followers_ and/or _following_ a user has and if these numbers _either_ **exceed** the number set OR **does not pass** the number set OR if **their ratio does not reach** desired potency ratio then no further interaction happens
505509
```python
506510
session.set_relationship_bounds(enabled=True,
507-
potency_ratio=1.34,
508-
delimit_by_numbers=True,
509-
max_followers=8500,
510-
max_following=4490,
511-
min_followers=100,
512-
min_following=56,
513-
min_posts=10,
514-
max_posts=1000)
511+
potency_ratio=1.34,
512+
delimit_by_numbers=True,
513+
max_followers=8500,
514+
max_following=4490,
515+
min_followers=100,
516+
min_following=56,
517+
min_posts=10,
518+
max_posts=1000)
515519
```
516520
Use `enabled=True` to **activate** this feature, and `enabled=False` to **deactivate** it, _any time_
517521
`delimit_by_numbers` is used to **activate** & **deactivate** the usage of max & min values

instapy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# flake8: noqa
22

33
# __variables__ with double-quoted values will be available in setup.py
4-
__version__ = "0.6.13"
4+
__version__ = "0.6.14"
55

66
from .instapy import InstaPy
77
from .util import smart_run

instapy/follow_util.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
""" Module which handles the follow features """
2+
# import built-in & third-party modules
3+
from random import randint
4+
from time import sleep
5+
26
# import InstaPy modules
37
from .util import web_address_navigator
48
from .util import get_username_from_id
@@ -69,6 +73,7 @@ def get_following_status(
6973
if not follow_button:
7074
browser.execute_script("location.reload()")
7175
update_activity(browser, state=None)
76+
sleep(randint(1, 5))
7277

7378
follow_button = explicit_wait(
7479
browser, "VOEL", [follow_button_XP, "XPath"], logger, 14, False

instapy/like_util.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,12 +471,17 @@ def get_links_for_username(
471471
# browser.wait_for_valid_authorization(browser, username, logger)
472472

473473
is_private = is_private_profile(browser, logger, following_status == "Following")
474+
474475
if (
475476
is_private is None
476477
or (is_private is True and following_status not in ["Following", True])
477478
or (following_status == "Blocked")
478479
):
479-
logger.info("This user is private and we are not following")
480+
logger.info(
481+
"This user is private and we are not following. '{}':'{}'".format(
482+
is_private, following_status
483+
)
484+
)
480485
return False
481486

482487
# Get links
@@ -487,7 +492,7 @@ def get_links_for_username(
487492

488493
if posts_count is not None and amount > posts_count:
489494
logger.info(
490-
"You have requested to get {} posts from {}'s profile page BUT"
495+
"You have requested to get {} posts from {}'s profile page but"
491496
" there only {} posts available :D".format(amount, person, posts_count)
492497
)
493498
amount = posts_count

0 commit comments

Comments
 (0)