tuxity / insta-unfollower

An Instagram script to unfollow accounts who doesn't follow-you-back
MIT License
384 stars 87 forks source link

JSONDecodeError #49

Closed parraml closed 3 years ago

parraml commented 3 years ago

Begin to unfollow users... Traceback (most recent call last): File "insta-unfollower.py", line 301, in main() File "insta-unfollower.py", line 290, in main while unfollow(user) == False: File "insta-unfollower.py", line 195, in unfollow response = json.loads(response.text) File "/usr/lib/python3.5/json/init.py", line 319, in loads return _default_decoder.decode(s) File "/usr/lib/python3.5/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)

PLEASE HELP

quadroli commented 3 years ago

@parrabram i to was facing the exact same issue, but i found this repo worked for me

parraml commented 3 years ago

@parrabram i to enfrentaba exactamente el mismo problema, pero encontré que este repositorio funcionó para mí

thank you very much for the recommendation, I will check it out right now

tuxity commented 3 years ago

You can try again, I have some changes

Zethrus commented 3 years ago

I'm getting this when using the script with both docker and non-docker Python 3.7. Error below is from docker version: Traceback (most recent call last): File "insta-unfollower.py", line 282, in <module> main() File "insta-unfollower.py", line 275, in main while unfollow(user) == False: File "insta-unfollower.py", line 190, in unfollow response = json.loads(response.text) File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

tuxity commented 3 years ago

I can't reproduce.

Try to add print(response.text) at line 190 just before response = json.loads(response.text)

Be sure to empty cache folder, and update local git repository to latest version too

Zethrus commented 3 years ago

print(response.text)

With that added before the response variables, here's the error: https://pastebin.com/LZBW14mG

tuxity commented 3 years ago

I think somehow you are not considered as logged in, did you remove files in cache directory ?

Zethrus commented 3 years ago

I think somehow you are not considered as logged in, did you remove files in cache directory ?

Strange, all I did was clear the cache directory before running the script. If I wasn't considered logged in, then how would it unfollow some of the other accounts. For the first few it seems to work fine.

Would it have anything to do with the cache directory being located in the same directory as the cloned git repo? It's located under ~/insta-unfollower/cache

gab1992 commented 3 years ago

Python 3.8.6 same error

It also happens the same on the other repo https://github.com/ricardojoserf/instagram-followers-bot with his program Exact same error, happen after also 15 unfollowing

Must have to do with instagram blocking unfollowing after 15 unfollow

tuxity commented 3 years ago

Oh it's only doing after few unfollows ? I thought it was on the first.

Then yes, it must be some kind of limit. I will more tests this weekend.

Zethrus commented 3 years ago

Oh it's only doing after few unfollows ? I thought it was on the first.

Then yes, it must be some kind of limit. I will more tests this weekend.

Is there any way I could edit the script to add a time to wait between each unfollow to possibly fix this? I don't mind running the script in a screen session oon a server all day if thats the case.

tuxity commented 3 years ago

Your account is a new account ? When googling instangram unfollow limits I found this:

    15 unfollows day 1
    20 unfollows day 2
    25 unfollows day 3
    30 unfollows day 4
    35 unfollows day 5
    40 unfollows day 6
    45 unfollows day 7
… and so on until I reach 150 unfollows/day
    1 unfollows/hr day 1
    2 unfollows/hr day 2
    2-3 unfollows/hr day 3
    3 unfollows/hr day 4
    3-4 unfollows/hr day 5
    4 unfollows/hr day 6
    4-5 unfollows/hr day 7

… and so forth until I reach a maximum of 13 unfollows per hour
Zethrus commented 3 years ago

Your account is a new account ? When googling instangram unfollow limits I found this:

Not new at all, 5+ years old. 2300+ following that I have to unfollow.

gab1992 commented 3 years ago

I ran it again, 17 unfollowed, and then the File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) on last line.

Account not new either, I think I have it since 2 years ago.

Easy fix would be to kind of reload the program in case of failure, BUT when I reload it straight after I have the error straight away. So it would need a timer and a restart. Edit : this time reloaded it straight away (after 10 unfollowed) and was able to unfollow 3. Still must be a limite but it's not precise...

gab1992 commented 3 years ago

Could the error come from account that are private and ask if you are sure you want to unfollow them ?

netayamin commented 3 years ago

the error comes up whenever a 429 response received and the message of this response is "Please wait a few minutes before you try again."

I was able to partly solve this using the following code in the unfollow func:

 if response.status_code == 429 : 
        return False

and with this code added to the main func so it will now loop the function instead of throwing an error:

  if unfollow(user) == False : 
                print("trying to unfollow %s again in 1 min" %(user["username"]))
                sleep(60)
                unfollow(user)

and by increasing the wait time between each unfollow request I believe this error shouldn't appear at all

R3test678 commented 3 years ago

Not even getting to unfollow one user, getting error (python 3.8.5)

Traceback (most recent call last): File "insta-unfollower.py", line 282, in main() File "insta-unfollower.py", line 275, in main while unfollow(user) == False: File "insta-unfollower.py", line 190, in unfollow response = json.loads(response.text) File "/usr/lib/python3.8/json/init.py", line 357, in loads return _default_decoder.decode(s) File "/usr/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)

tuxity commented 3 years ago

Sorry for the mega late response, I will check this again. I will try to confirm @netayamin answer and implement the code if needed.

tuxity commented 3 years ago

I managed to get temp banned from Instagram by Following a lot of people in a short time. I can confirm the fix @netayamin did is working well! Thank you