Hello friend, how can i prevent to follow user that already follow me?
thanks for the support.
I hope that everything is explain well
UP
@uluQulu help please
hi @cormo1990
follow_user_followers
_)hi @uluQulu the answers to your questions are:
Follow_user_followers
IG show Follow Back button
Great! @cormo1990
_2nd step_ is very important, if you really see _Follow Back_ button it will be so much easier for writing the desired change
To make sure, please share the screenshot of that button in the same dialog box. (_to guarrantee that we are gonna modify the right way_)
I think in the future every user will see _Follow Back_ button in web browsers, too, but at this moment it is possibly in beta test. _E.g._ I still see _Follow_ button in the same dialog box, whilst some buddy from Italy see _Follow Back_ everywhere...
@uluQulu I am italian, and after what you wrote in the previous answer, i did some checks with changing browsers and PCs and it is incredible...i don't understand why but not in all browser and pc i can see that button of follow back...so i suppose that edit is helpful just for a few user...the other changes is so difficult?
Super job! @cormo1990
I meant the simplicity of the modifications, none of them is difficult
Well I thought again and realized that we can make it possible with the same set of accuracy using the other method. And will even make it much faster than the prior "Follow Back" method by just adding a new single variable inside InstaPy class ^^;
@uluQulu your job is the hardest bro! thanks again for support all the community...
_i've caught seasonal grip that's why it took lots of time to test within ill state, but it is ready_
you will edit several places in 3 files, @cormo1990 (_mostly small changes π©_ )
File 1: instapy.py
#1 import new function get_watchers
near other imports
from .util import validate_username
from .util import get_watchers ##you will add this new line
#2 add a new parameter to follow_user_followers
method, called non_watchers
def follow_user_followers(self,
usernames,
amount=10,
randomize=False,
interact=False,
sleep_delay=600,
non_watchers=False): ##here is the new line to be added
#3 add the content of the newly added parameter non_watchers
near the _previous line_ above
if not isinstance(usernames, list):
usernames = [usernames]
"""We will get our current followers using graphlql queries""" ##add this new line
my_watchers = get_watchers(self.browser, self.username, self.logger, self.logfolder) if non_watchers else None ## add this new line, too
#4 in the same method of follow_user_followers
, find this variable below and pass the new parameter
try:
userFollowed += follow_given_user_followers(self.browser,
user,
amount,
self.dont_include,
self.username,
self.follow_restrict,
randomize,
sleep_delay,
self.blacklist,
self.logger,
self.logfolder,
self.follow_times,
my_watchers) ##you will add this new line
File 2: unfollow_util.py
#1 find follow_through_dialog
function and add a new parameter
follow_through_dialog(browser,
logger,
logfolder,
follow_times,
my_watchers=None, ##you will add this new line
callbacks=[]):
#2 in the same follow_through_dialog
function, add new lines to provide the new functionality
if (person not in dont_include and
follow_restrict.get(person, 0) < follow_times):
if my_watchers is not None: ##add the lines below until `sleep(2)` line
if person in my_watchers:
logger.info("Jumped following '{}' who ALREADY is following you ;-)".format(person))
sleep(7)
continue
else:
my_watchers.append(person)
sleep(2) ##last line to add
followNum += 1
#3 you will add a new parameter: my_watchers
to the end of parameters of the function below
follow_given_user_followers(browser, user_name, amount, dont_include, login, follow_restrict,
random, delay, blacklist, logger, logfolder, follow_times):
random, delay, blacklist, logger, logfolder, follow_times, my_watchers):
#4 you will pass a new parameter: my_watchers
to the end of parameters of the function call below (_find this line _inside_ the same function above this_)
persons_followed = follow_through_dialog(browser, user_name, amount, dont_include, login,
follow_restrict, user_followers_count, random, delay,
blacklist, logger, logfolder, follow_times,
blacklist, logger, logfolder, follow_times, my_watchers,
callbacks=[])
File 3: util.py (easiest modification)
#1 import _json_ at top of file neat other imports
import sqlite3
import json ##you will add this new line
#2 add this new function: get_watchers
to the end of the util.py
I've gisted it for ease of modify, get it here
YES it has been huge and seen huger in this comment but it is the most optimal way of doing this portably for every user. But if we would do it with Follow Back
button, it would not take more than 2 lines xD
Performance stays the same between the other so-called method, the difference is it will get the entire list of your followers before starting the feature (follow_user_followers
in this case) and aveargely, for an accaunt with 10k followers it will take about ~6 minutes, this will happen only once the feature is initialized, never again,.
Being dramatically ill, I hope I did not miss some indentation, or a fuzzy variable. But if something does not work as expected, just ask, I will help :_)
@cormo1990 I forgot the usage xD
after applying the new lines above,
just add the new parameter: non_watchers
to activate desired functionality inside your quickstart script to the follow_user_followers
feature as in below:
##inside the quickstart script
session.follow_user_followers(usernames=['Popeye', 'Sindrella'], amount=10, randomize=False, interact=False, sleep_delay=600, non_watchers=True)
by default non_watchers
will be disabled (with the value of False
), so make sure to enable it with the value of True
AND it will do the job you have requested above: _Follow only the people who does not already follow me whilst jumping over the others..._
And with a slight change, it can be applied to other features easily by just passing the new variable...
if you can't manage to apply the changes properly, share your up-to-date files (_all of the required 3_), I will help :))
@uluQulu I've just finish to edit the files.
during the running the browser see an uncountable number of lines of codes but when it finished I THINK that everything works good!!! :)
Below the result! :) you do an excellent job my buddy, the explaination is simply and clear
The last thing is how can I follow for example all the followers of an account of 10K followers?
Thanks again for all and I hope that this implementation can help also other user
_Those uncountable lines of codes_ are shown while the way graphql queries work (_and yes it is does no harm_ :)
Otherwise we had to scroll down that Followers
dialog until hits bottom box which would take much more time (at least ~%35 more than graphql
approach)
It is great that we have accomplished this without problems and you should know that I did not write that graphql
_ing_ part in the get_watchers()
function, just used the existing function in unfollow_util.py (_see it in the unfollow()
function's elif onlyInstapyFollowed is False and onlyNotFollowMe is True:
condition_) and _removed it's following part_ to keep only _followers part_ that we only needed for this change to work, thanks to the guys who wrote those lines
If I understood well, you want to follow all of the users _regardless of_ they follow you _or not_. _Well_, it means you will _switch off_ the newly written parameter, so non_watchers=False
will do the job (_or you can remove the parameter from your feature, it will also do the job, cos it's default value is False
_)
And it does not matter _whether the_ target username has 10k followers or 100k followers, cos our new parameter, does only this change: _get your username's entire followers_ -> and during the following actions, _compare the usernames againist your entire list of followers (if user exists, it jumps follow, else adds the user to the generated list...)_. So the target user's _followers count_ makes no sense..
Welcome, @cormo1990 it's a pleasure to write new stuff, since I learnt some new tips on graphql during working on this, have a good use!
@uluQulu No, i mean, my target are all the followers of 10K account and skip the accounts that already follow me but when i launch the bot it stopped after 79 user and i don't know why.
in the settings i wrote 1000 user to follow not 79...
BTW this implementation is excellent
Okay @cormo1990 I got it, it is possibly another issue of getting less users than desired and I remember we dealt with this issue in #1548, in your request
Did you have the changes from that page while ended up with _79 users_ issue?
If you have applied those changes to the current file (unfollow_util.py) and still the same problem occurs, tell me to find a way to debug it further.
@uluQulu I didn't solved that issue...what I have to modify in my files? I uploaded all my configuration...I can't find the mistakes...can you check and reupload the fixed version of that files please?
thanks again
@cormo1990 for the fix in #1548 we only need unfollow_util.py modified
I've applied all the three steps of the fix in that page, here is the zipped file π
@uluQulu I've just tested your version, the bot works but the result is the following...probably something go wrong..any suggestion buddy?
@cormo1990
it is the sign of you've hit scroll limit and it can't open up new usernames
IG has really messed up with scrollers and customized timeouts, very bad :/
in the last try, how many usernames it could get?
@uluQulu 250, i tryed to count the number of scroll and I suppose it is around 7 times and after it appear like blocked...are there any solution?
thanks a lot buddy
@cormo1990
Find sc_rolled += 1
line in your current unfollow_util.py file and add a new line for test purposes after it
sc_rolled += 1
print("\n\nIt has scrolled {} times\n\n".format(sc_rolled))
This way we can see the accurate amount of scrolls
Also take the test in 2 situations:
a) after a big break using IG (start same feature e.g. after 1 hour of break)
b) after a busy usage (start the feature after some other scroller busy feature, e.g. like_by_tags)
This will help us get the average scroll limit tested in different activity frequencies.
After we find out the behaviour, we will figure out a way to deal with itβ
@uluQulu Excellent work as always!
First test done, it has scrolled 9 times
@uluQulu hello friend, I tested more times and it has scrolled always 9 times.
I compare that with the main version downloadable of InstaPy and it scrolled faster and more times.
i hope that info and tests can help you to find the solution :)
thanks in advance for you brilliant support...
If you will come to Italy I have to offer you a big dinner :)
@uluQulu Update: i tryed to follow followers from an user that i have already followed account and scrolled only 6 times...i don't know why...
@cormo1990
you mean you've tried with non_watchers=False?
It can be related to the activity from graphql also affects other scroller timeout.
How many followers do you have in the accaunt(s) where you did end up with 9 scrolls (_or 6 scrolls_)?
@uluQulu i tried with different account, always 9 scroll with 40K account, 20K account 15K account and 5K account, only one time with 5K account scrolled 6 times...
with non_watchers=False scrolled 15 times...so I suppose that depends to graphql right?
@uluQulu after setting "false" I can't run again the bot and the traceback is the following...
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 859, in emit
msg = self.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 732, in format
return fmt.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 471, in format
record.message = record.getMessage()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 335, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Logged from file util.py, line 345
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 859, in emit
msg = self.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 732, in format
return fmt.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 471, in format
record.message = record.getMessage()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 335, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Logged from file util.py, line 345
@uluQulu I restart my pc, and the error returned is the fb logo with sorry we will back as soon as possible....probably an graphql bug?
@cormo1990
Can you make sure you have not edited any further place?
For overall changes, you should edit only 3 files: instapy.py, unfollow_util.py (_are you using the same of this file I shared above?_), util.py and not any other file.
Although I did not understand the latest traceback's reason, but this change will fix it it
in util.py, modify get_watchers function like this:
except BaseException as e:
logger.info(
"Unable to get followers information \n", str(e))
will be
except BaseException:
logger.info("Unable to get followers information\n")
raise
Also, with non_watchers=False
it should scroll 87 times as it does for me. (_cos i put break time after 85 scrolls_) but i see it scrolls only 15 times, very weird
First, approve you've not any other edit mistakes in all of the three files
We will increase the timeout after graphql finishes its job
In util.py, modify get_watchers function like this
my_watchers = list(set(all_followers))
sleep(3)
will be
my_watchers = list(set(all_followers))
sleep(566) #first, test with this 10 minutes regular IG timeout interval, if it works, try testing with less minutes
My accaunt is around 3k so, in my tests it did 30 scrolls in one, and 60 scrolls after a big break but after this change it will scroll 85 times before sleeps some more, hopefully
@cormo1990
Can you screenshot that facebook error, at which step it did occur, is it consistent, does it happen on all of your accaunts, try to provide detailed information in order to find a solution
try not to overuse querying graphql from the same IP, you can exceed limits without knowing while testing it :)
@uluQulu Well Done Buddy!!! I do the modify suggests by you in the previous posts and now seems like works good...it scrolled 21 times for reached 200 user to follow.
it takes 15 minutes before starting to scroll from when I run the bot.
probably in the previous test I abused of querying graphql from the same IP.
I'll do other test in the next days. keep in touch
again awesome work man
thanks @cormo1990!
did it get 200 posts out of given 1000? (_i mean it failed again to get the desired amount of links?_)
As I said above, with this seasonal updates IG stricted activity frequency to certain timeouts with flexible limits that's why we have to take breaks before IG cuts access with Too Many Requests
ERROR.
Good new is that we can change our style to be effective as before, e.g. now, starting features with higher amounts is more convenient, cos, the longer time consuming part is getting links which happens mostly only at start of the features.
Although it is known that IG gives back access after 10 mins of time in many places, but you can test with lower time intervals to see if it works (_e.g. in the last change we did, (
sleep(566)
) change it to lower value likesleep(427)
or much lower likesleep(255)
, I mean it's up to the tests done in this particular_ part)
Another option is using graphql in other scrollers, too, but it does change lots of things and graphql access is more noticable than native scrollers regarding the seamless activity, but it is the future ;)
@uluQulu no it get the desired amount of links 200/200 π π₯
yes in the next days I try to set lower value to sleep but honestly it is good also wait 10/15 minutes in my opinion.
thanks for all your precious work, I am sure that with your contributes in the future this bot will be always better
It's superb that it works for you πͺ
You would do the same! @cormo1990 π (_btw you're nice going with your accaunts, hooray for you!_)
Pity that I've already quitted using IG & InstaPy but turns out your efforts on strongly helpful feedbacks puts you at the top, you have earned my respect, when needs help with another new feature to be implemented, just mention my nickname, I will help, hopefully!
@uluQulu I didn't change anything...Where is the problem? thanks in advance buddy
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 859, in emit
msg = self.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 732, in format
return fmt.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 471, in format
record.message = record.getMessage()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 335, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Logged from file util.py, line 346
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 859, in emit
msg = self.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 732, in format
return fmt.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 471, in format
record.message = record.getMessage()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 335, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Logged from file util.py, line 346
This is the message showed by the browser when bot crashed
{"message": "rate limited", "status": "fail"}
@cormo1990
{"message": "rate limited", "status": "fail"}
is a well known Error Code
of 419 meaning 'Too many requests sent!'
You've most probably exceeded limits of graphql queries, slowing down querying will help
And for the error above, I think , the exception it throws includes some curly braces or percent signs which makes python string formatter crash
To solve, just remove raising that exception in util.py
except BaseException:
logger.info(
"Unable to get followers information\n")
raise #you will remove this line
But
raise
should be safe, I don't know how it could happen..
@uluQulu Thanks a lot, but in your opinion should I don't remove raise in util.py?
this evening I try do restart both and I'll let you know something
dear @uluQulu
Update:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 859, in emit
msg = self.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 732, in format
return fmt.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 471, in format
record.message = record.getMessage()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 335, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Logged from file util.py, line 346
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 859, in emit
msg = self.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 732, in format
return fmt.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 471, in format
record.message = record.getMessage()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 335, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Logged from file util.py, line 346
Buddy, it doesn't work, I also try to delete raise line in util.py
I don't know what to do...any ideas?
thanks a lot
Hey @cormo1990
I think another exception happened else than BaseException
, that's why it feels not to raise...
try this (_in the same file -_ util.py):
except: #you will remove BaseException word from this line
logger.info(
"Unable to get followers information\n")
raise #you will keep this raise line
And generally, you've either hit timeout or some other error while querying, this change will help us find the source of the problem, hopefully
@uluQulu this is the traceback after your latest suggestion buddy, thanks again
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 859, in emit
msg = self.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 732, in format
return fmt.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 471, in format
record.message = record.getMessage()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 335, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Logged from file util.py, line 346
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 859, in emit
msg = self.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 732, in format
return fmt.format(record)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 471, in format
record.message = record.getMessage()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 335, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Logged from file util.py, line 346
@uluQulu IMPORTANT UPDATE:
I run the bot with another mine account with 5000 followers and works good...
my main account has 10K followers...is it possible that the issue is in a limit or something regarding the number of followers?
thanks again buddy
@cormo1990
Post the full console output after the last working logger message (include full error code)
You are right, but let's find the exact problem
@uluQulu this is my full console message...
@cormo1990
Try new variable in get_watchers
function:
sc_rolled=0 #add this
try:
has_next_data = True
And
url = (
'{}&variables={}'
.format(
graphql_followers, str(json.dumps(variables)))
)
sleep(2)
browser.get(url)
sc_rolled+=1 #add this line
print ("\nScrolled {} times\n".format(sc_rolled)) #add this line
Try with your big acc and tell max scroll amount (test a few times with at least 10 min of break)
@uluQulu Done buddy, it scrolled only 1 times...so this is what it was written on the console but I saw the page refresh more times...and after happened the same error...
Impossible @cormo1990 it should scroll more and more times, have you applied the indentation correctly? (_Post a screenshot of that part in source code?_)
I meant refresh == scroll
@uluQulu here the code of util.py
@uluQulu below the screenshot, the numbers of refreshes on browser are a lot but in the console is written only one scrolling...
I hope that it can help you to find the issue buddy
@cormo1990 you have patched other very similar place π patch correct place
@uluQulu thanks a lot, sorry for my mistake.
now I can see that the bot crash at 100 scroll, works good until 99 scrolls and then crashed...so I suppose there is some limit on number of scrolling to 100?
thanks
@cormo1990
Assuming you have tested a few times with at least 10 mins of breaks, now, we know the max scroll count (_if you have not tested more than 1 times, please do it now, and find the accurate average amount of possible scrolls_)
Add some new lines to the last modified file:
sc_rolled+=1
print ("\nScrolled {} times\n".format(sc_rolled)) #remove this line
if sc_rolled > 91: #add this new line
logger.info("Queried too much! ~ sleeping a bit :>") #add this new line
sleep(600) #add this new line
sc_rolled = 0 #add this new line
Now, after _every_ 91 times of scroll, it will take a break until current max requests' timeout finishes (in ~600 seconds)
You can change 91 to even 98, but I took a safe number (_if you find the max scroll value different than 99 in future tests, always put a lower value to the sleep timeout controller in
if sc_rolled > 91:
line, it will prevent crashes and will continue after requests timeout finishes..._)
@uluQulu another excellent work my friend!
first of all thank you again, I tried 5 times for obtain the average number of scroll (I confirm that the number incriminated was 100). after I modify with your suggestion the file util.py and tested.
Now works GOOD! π
@uluQulu Man, are there other limitations of using that? for example the number of starts of querying?
because after using 5 times today, now don't work again... with the same error...I tried to decrease the number of scrolling before sleep but it doesn't work
@uluQulu awesome job!
Can we update the current instapy files with this once its working fine? π
@uluQulu yes probably there are some limitation of querying but after a few hours works good again.
thanks man
@cormo1990
It might be the case if there is a daily querying limit to graphql sources, if it is so, we have nothing to do but to handle it. But let's make sure what is going one here
Please, provide details:
But if there is really a daily querying limit, it is really a bad news :/
Also, for scrollers (_with bars_), there is not yet daily limit (_it seems so_), but only momentarily (_max limit per ~10 minutes_) timeouts...
Yes, this feature is wished by many in the community, PR will be good! :>
@uluQulu
I don't remember exactly...but next time i'll try to count how many times it works.
Around 10/12 K followers more or less
Only one account until crashed
No, i haven't thought to do that test, next time i will.
The error is the same reported in the other post above...redirect to the file util.py
I'll do some other test in the next days and i let you know if happen again.
thanks again
@cormo1990 Can you please upload your files?
I edited everything like you guys said and get this error:
C:\Users\LordKek\Desktop\Instax>python 12.py
Traceback (most recent call last):
File "12.py", line 1, in <module>
from instapy import InstaPy
File "C:\Users\LordKek\Desktop\Instax\instapy\__init__.py", line 2, in <module>
from .instapy import InstaPy
File "C:\Users\LordKek\Desktop\Instax\instapy\instapy.py", line 36, in <module>
from .util import get_watchers
ImportError: cannot import name 'get_watchers'
Could you please explain this sentence a little more?
2 add this new function: get_watchers to the end of the util.py
I've gisted it for ease of modify, get it here
I think i messed up there
thanks in advance!
@condomfighters hi, you can find my file zipped below.
all the credits of that implementation are of @uluQulu π₯ :smile:
@cormo1990 thanks a lot!
Did you have this error by any chance?
File "C:\Users\LordKek\Desktop\Instax\instapy\instapy.py", line 146, in __init__
self.set_selenium_local_session()
File "C:\Users\LordKek\Desktop\Instax\instapy\instapy.py", line 213, in set_selenium_local_session
chromedriver_location = Settings.browser_location
AttributeError: type object 'Settings' has no attribute 'browser_location'
if so, what did you do to fix it?
hey @cormo1990
having considered IG does have a daily queries limit (_either, particularly to querying followers
or it does apply to entire usage_), let's do our part to prevent it cause crashes!
You will add a new recorder to keep track of overall queries per day, and after we find the accurate daily limit, we will use it.
Now apply these small changes:
self.logfolder
, too, while calling get_watchers
functionmy_watchers = get_watchers(self.browser, self.username, self.logger, self.logfolder) if non_watchers else None ##we added `self.logfolder` here inside paranthesis....
logfolder
def get_watchers(browser, username, logger, logfolder): ##we added `logfolder` here
sc_rolled+=1
and if sc_rolled > 91:
lines, add these new lines below:sc_rolled+=1 ##add all lines below
try:
filename = '{}watchers_queries.json'.format(logfolder)
sc_rolled_date = datetime.date.today().strftime('%Y-%m-%d')
if not os.path.isfile(filename):
with open(filename,'w+') as sc_rolled_data:
json.dump({}, sc_rolled_data)
sc_rolled_data.close()
"""Loads the existing data"""
with open(filename) as sc_rolled_data:
sc_rolled_all = json.load(sc_rolled_data)
sc_rolled_all[sc_rolled_date] = sc_rolled_all.get(sc_rolled_date, 0) + 1
"""Dumps the current data"""
with open(filename, 'w') as sc_rolled_data:
json.dump(sc_rolled_all, sc_rolled_data)
sc_rolled_data.close()
except:
raise
if sc_rolled > 91: ##add all lines above
Now you can open up your logs
folder in your file explorer and find the new watchers_queries.json file which holds the daily queries count in "2018-04-11": 16
format.
From now on, you should check that file several times when you encounter a daily limitage and then tell the values to find the average limit. Only then we will put a tracker into InstaPy in order to prevent crashing after exceeeds the limit....
If I have missed something, please notify, I will help
I've also updated the original fix above, so, feel free to reapply from there, too!
Nero, it is never good to use other guys' file(s), cos they might have other modifications, too, which will cause incompatibilities with yours. Always try to manually apply the changes.
Now, upload your original working files (instapy.py, util.py, unfollow_util.py), I will help
P.S.
_"2. add this new function: get_watchers to the end of the util.py
I've gisted it for ease of modify, get it here"_ meant,
you will addget_watchers
function to the bottom of the util.py file, you can get that function from here
@uluQulu Thank you so much for the help
and yeah i just noticed that cormo is using mac
unfortunately, i overwrote cormo's file with mine so i need to redo everything
once i do i'll upload them here.
i'm a noob so it will take time..
idk if you were talking about modified files or my current files, so i'll upload them anyway
thanks again
util.zip
instapy.zip
unfollow_util.zip
Nero, if you have no further modifications, I can get the up-to-date files from main repo and edit them
Are those files you have shared above working for you?
@uluQulu yes these work fine right now, thank you very much for your help!
Here Nero,
instapy.zip
unfollow_util.zip
util.zip
@uluQulu thanks a lot for the help man.
I'm not sure what the bot was doing but the first few pages it browsed were like this
After a few 20 followers the bot stopped when I changed the number of followers to 500 from 10
i got this error.
I deleted my cookies, cache & history and got the same issue
i changed the amount back to 10 and still got the same issue.
searched online but found nothing about this problem
any clue what i did wrong?
Nero,
What you see in the first attached screenshot is the way graphql queries work, there is no any problem into that.
But the error you saw in the seconds attacfhed screenshot, Access denied
, is weird, I have seen it first time, but I think may be they changed some graphql endpoints...or maybe you have exceeded the limit of graphql queries during tests, I can't be sure, does it work after a few hours?
@uluQulu thanks for the info, I was really worried when it went on the queries page xD
Just tested the bot right now after waiting a day and it works π π π
thank you for this amazing support btw! I want to return the favor but I'm a noob in python but I do have skills in graphic design so if you ever need anything just ask!
@uluQulu this is a mistery....
MBP-di-:InstaPy_7 $ python _FollowSingle.py
INFO [2018-04-12 14:26:35] [] Session started - 2018-04-12 14:26:35
INFO [2018-04-12 14:27:05] [] Logged in successfully!
INFO [2018-04-12 14:31:06] [] Queried too much! ~ sleeping a bit :>
WARNING [2018-04-12 14:53:31] [] There are 0 people to follow
ERROR [2018-04-12 14:53:57] [] following_link error list index out of range
INFO [2018-04-12 14:53:57] [] Session ended - 2018-04-12 14:53:57
INFO [2018-04-12 14:53:57] [] --------------------
Traceback (most recent call last):
File "LC_FollowSingle.py", line 37, in
session.follow_user_followers([''], amount=600, randomize=False, interact=False, non_watchers=True)
File "/Users//Desktop/InstaPy_7/instapy/instapy.py", line 1426, in follow_user_followers
my_watchers)
File "/Users//Desktop/InstaPy_7/instapy/unfollow_util.py", line 818, in follow_given_user_followers
allfollowing,
UnboundLocalError: local variable 'allfollowing' referenced before assignment
@cormo1990 I had something similar, try changing the usernames in your _FollowSingle.py file.
I put 1 account instead of 2.
Hey guys,
After the latest graphql endpoint updates, querying parameters changed and I've just updated this feature with that change, _to use solution_, re-apply get_watchers
function in util.py with revised gist.
Now it should work properly without
Acess Denied
errors.
@cormo1990, that error,local variable 'allfollowing' referenced before assignment
still happens?
@uluQulu hey friend, yes that error happen again.
Now I try to implement your modify and test.
Thanks again for the support
UPDATE:
@uluQulu again another awesome work buddy, the modify works good! well done π :)
Thank you for the update @uluQulu
Unfortunately, my bot crashes when I try to run it but it's not because of the new update.
I've had this problem before your update too.
If I figure this out I'll post the solution here for future users.
thanks again for the support!
File "C:\Users\LordKek\Desktop\Instax\instapy\instapy.py", line 117, in __init__
self.follow_restrict = load_follow_restriction(self.logfolder)
File "C:\Users\LordKek\Desktop\Instax\instapy\unfollow_util.py", line 908, in load_follow_restriction
return json.load(followResFile)
File "C:\Users\LordKek\AppData\Local\Programs\Python\Python36\lib\json\__init__.py", line 299, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "C:\Users\LordKek\AppData\Local\Programs\Python\Python36\lib\json\__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "C:\Users\LordKek\AppData\Local\Programs\Python\Python36\lib\json\decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\LordKek\AppData\Local\Programs\Python\Python36\lib\json\decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Welcome Nero,
That issue is unlreated to this thread.
It possibly happened after you've forcibly ended some session where it corruptly dumped data to JSON
file,
_for solution_, either find that corrupt element in followRestriction.json
file and fix it or just reset that file (_keep only this in there:_ {}
)
note that
followRestriction.json
file keeps records to be used withfollow_times
parameter
@uluQulu Thanks a lot! I can't believe it was that simple.
My access is still denied even after updating.
I tried to get access by using a hotspot from my phones 4g, it worked the first time but now i keep getting access denied on 4g too.
could you please explain in a little more detail what you mean with
re-apply get_watchers function in util.py
thank you!
My pleasure, Nero,
Open this gist and click on RAW button there and then copy all lines of code (_CTRL+A_ & _CTRL+C_),
then open up util.py file and _find_ & _replace_ entire get_watchers
function with the one you have copied from the gist.
If you have applied revised function successfully and still have problems, ask me, hopefully I will help.
@uluQulu It's working!! thank you for the support!
Are you planning to pull request this?
This is a very useful option to have π
Nero,
It is great that it works for you!
At this state, this newly written parameter- non_watchers
works with only follow_user_followers
feature, but if I get some free time, I will write some new lines to make it support more features and then it would be better to be merged.
You're right, this is one of the useful features I also wanted to have for some time, but never did implement before...
@uluQulu Happy to hear that, if there is somehow I can help. just ask
im allways getting unexpected keyword argument 'non_watchers' with follow_user_followers
instapy.py:
def follow_user_followers(self,
usernames,
amount=10,
randomize=False,
interact=False,
sleep_delay=600,
non_watchers=False):
userFollowed = []
if not isinstance(usernames, list):
usernames = [usernames]
my_watchers = get_watchers(self.browser, self.username, self.logger, self.logfolder) if non_watchers else None
hi @nafferro,
In some place, you should provide that formal argument of non_watchers
in order to operate properly.
Make sure, the changes you've applied is analog with these modifications in the main comment above.
@uluQulu i already rewrote everything on instapy.py, unfollow_util.py and util.py
@nafferro,
non_watchers
variable is used in 2 places only and it seems identical in your attached file.
I got a feeling that you are passing non_watchers
parameter to some unsupported feature, like a _similar_ one- follow_user_following
, you should know that, currently, this functionality is supported only for follow_user_followers
feature.
_If you have no problem with the above statement then, having seen the full console output pointing that unexpected keyword argument
error would help for find the misbehaviour..._
def __init__(self,
username=None,
password=None,
nogui=False,
selenium_local_session=True,
use_firefox=False,
page_delay=25,
show_logs=True,
headless_browser=False,
proxy_address=None,
proxy_chrome_extension=None,
proxy_port=0,
bypass_suspicious_attempt=False,
multi_logs=False,
non_watchers=False):
If i add non_watchers to __init__ it fixes
Hey @nafferro,
I have a guess that you are passing non_watchers
variable to InstaPy
instance in your quickstart script
session = InstaPy(username=insta_username,
password=insta_password,
headless_browser=False,
multi_logs=True,
non_watchers=True) ## WRONG
_That can be the reason why you are having troubles._
follow_user_followers
featuresession.follow_user_followers(usernames=['Popeye', 'Sindrella'], amount=10, randomize=False, interact=False, sleep_delay=600, non_watchers=True)
See the usage in this comment: https://github.com/timgrossmann/InstaPy/issues/1732#issuecomment-376583156
LOL
i'm feeling so dumb
@nafferro,
Having not known the people's programming knowledge in the counter part of the screen, I tend to write modifications & instructions at the easiest level possible so that every person can understand.
_Moreover I am also very new in programming..._
Hope you understand!
hello, I followed the steps above and now I have this error report:
follow loop error name 'my_watcher' is not defined
how can I fix that?
hi @sxraby,
make sure you want my_watcher
or my_watchers
_cos in the implementation above, exists no any keyword named my_watcher
_
oh sorry, made a typing mistake... thanks for the help!
@uluQulu thanks so much! I deleted the json file and my script started working again with no errors!
Glad to help @Dankartpage
Going to prepare a workaround to handle those situations cos it happens to many users many times due to those obvious reasons.
Hi @uluQulu,
I am adding your code to my files, but what's remarkable is that my code is just at alot of places is much different. I don't get it. My code is up to date, but it's alot different than yours. For example, the function follow_given_user_followers doesn't even exist in my unfollow_util.py folder... how is that possible? Should I add that function or should I just completely copy your instapy files and use them instead?
@aku6640
Right, there is no follow_given_user_followers
definition now.
I myself have changed the design of that particular part :D
And recently I have prepared a newer and better implementation which will make this functionality available in ALL of the features! If you could wait a few days, I will share it in my future PR.
But if you still want to apply the changes in this page, I can modify it to work again.
@uluQulu
then I will wait for the new implementation. Can we pull them or also manually adjust like this solution?
So you suggest not to make the changes in this thread, but wait for the better implementation?
@aku6640
While implementing this data grabbing feature sets, I used the same structure of get_watchers
definition shared in this thread, cos it has been improved to the best with the help of @cormo1990.
What is new is that this time, it is greatly integrated into the program and those functionalities can be accessed and used with any feature you can think of.
This time I will PR it to get merged into the main repository, that's why you will not need to apply it manually.
But I cannot give you a fixed time when it will be available cos I already have an existing PR in there and only after it, I will share the new feature sets. So check PRs this week, it can be there any time :)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this problem still occurs, please open a new issue
Hello,
I would like to have some help to make a function similar to this. Can you help me ?
Most helpful comment
It's superb that it works for you πͺ
You would do the same! @cormo1990 π (_btw you're nice going with your accaunts, hooray for you!_)
Pity that I've already quitted using IG & InstaPy but turns out your efforts on strongly helpful feedbacks puts you at the top, you have earned my respect, when needs help with another new feature to be implemented, just mention my nickname, I will help, hopefully!