TnYtCoder / InstaFans

A Python Script To Increase Instagram Followers ⬆️
GNU General Public License v3.0
54 stars 14 forks source link

instagrapi.exceptions.ClientBadRequestError: Unknown ({'message': '', 'response': <Response [400]>, 'status': 'fail'}) #10

Closed misbagas closed 7 months ago

misbagas commented 7 months ago

I tried to execute the program by using this code python3 instafans.py then I got this error

int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/instagrapi/mixins/user.py", line 189, in user_info_by_username
    user = self.user_info_by_username_gql(username)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/instagrapi/mixins/user.py", line 142, in user_info_by_username_gql
    return extract_user_gql(self.public_a1_request(f"/{username!s}/")["user"])
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/instagrapi/mixins/public.py", line 173, in public_a1_request
    response = self.public_request(
               ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/instagrapi/mixins/public.py", line 72, in public_request
    return self._send_public_request(url, **kwargs)                                                                                                        
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                        
  File "/usr/local/lib/python3.11/dist-packages/instagrapi/mixins/public.py", line 106, in _send_public_request                                            
    expected_length = int(response.headers.get("Content-Length"))                                                                                          
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                          
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'                                                           
400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/friendships/61241301387/following/?rank_token=59256404594_8eebf9eb-f95a-4413-bd4c-3270ca45cded&search_surface=follow_list_page&includes_hashtags=true&enable_groups=true&query=&count=10000                                                     
Traceback (most recent call last):                                                                                                                         
  File "/usr/local/lib/python3.11/dist-packages/instagrapi/mixins/private.py", line 298, in _send_private_request                                          
    response.raise_for_status()                                                                                                                            
  File "/usr/local/lib/python3.11/dist-packages/requests/models.py", line 1021, in raise_for_status                                                        
    raise HTTPError(http_error_msg, response=self)                                                                                                         
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/friendships/61241301387/following/?rank_token=59256404594_8eebf9eb-f95a-4413-bd4c-3270ca45cded&search_surface=follow_list_page&includes_hashtags=true&enable_groups=true&query=&count=10000                      
Status 400: Empty response message. Maybe enabled Two-factor auth?                                                                                         
Traceback (most recent call last):                                                                                                                         
  File "/usr/local/lib/python3.11/dist-packages/instagrapi/mixins/private.py", line 298, in _send_private_request                                          
    response.raise_for_status()                                                                                                                            
  File "/usr/local/lib/python3.11/dist-packages/requests/models.py", line 1021, in raise_for_status                                                        
    raise HTTPError(http_error_msg, response=self)                                                                                                         
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/friendships/61241301387/following/?rank_token=59256404594_8eebf9eb-f95a-4413-bd4c-3270ca45cded&search_surface=follow_list_page&includes_hashtags=true&enable_groups=true&query=&count=10000                      

During handling of the above exception, another exception occurred:                                                                                        

Traceback (most recent call last):                                                                                                                         
  File "/home/misbahskuy/Desktop/InstaFans/instafans.py", line 130, in <module>                                                                            
    celeb()                                                                                                                                                
  File "/home/misbahskuy/Desktop/InstaFans/instafans.py", line 82, in celeb                                                                                
    followings = api.user_following(user_id)                                                                                                               
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                               
  File "/usr/local/lib/python3.11/dist-packages/instagrapi/mixins/user.py", line 550, in user_following                                                    
    users = self.user_following_v1(user_id, amount)                                                                                                        
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                        
  File "/usr/local/lib/python3.11/dist-packages/instagrapi/mixins/user.py", line 509, in user_following_v1                                                 
    result = self.private_request(f"friendships/{user_id}/following/", params=params)                                                                      
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                      
  File "/usr/local/lib/python3.11/dist-packages/instagrapi/mixins/private.py", line 445, in private_request                                                
    raise e                                                                                                                                                
  File "/usr/local/lib/python3.11/dist-packages/instagrapi/mixins/private.py", line 432, in private_request                                                
    self._send_private_request(endpoint, **kwargs)                                                                                                         
  File "/usr/local/lib/python3.11/dist-packages/instagrapi/mixins/private.py", line 360, in _send_private_request                                          
    raise ClientBadRequestError(                                                                                                                           
instagrapi.exceptions.ClientBadRequestError: Unknown ({'message': '', 'response': <Response [400]>, 'status': 'fail'})      

I changed the credentials.ini file to my account name and password

TnYtCoder commented 7 months ago

Is your I'd private or something?

misbagas commented 7 months ago

no, I am not private my account

TnYtCoder commented 7 months ago

Please check your internet connection, it's a bad connection error. Try to run that again with good connection

misbagas commented 7 months ago

all right, my internet is good.

TnYtCoder commented 7 months ago

That's Nice,

Is your Instagrapi package installed smoothly? You can try running code in replit, replit will install packages without any error.

misbagas commented 7 months ago

how to do it

TnYtCoder commented 7 months ago

It's a website and Android mobile app, available at every store ig. Try there