ohld / igbot

🐙 Free scripts, bots and Python API wrapper. Get free followers with our auto like, auto follow and other scripts!
https://hikerapi.com/p/N2P6iqiM
Apache License 2.0
4.69k stars 1.47k forks source link

Request returns 405 error! #756

Closed renevt closed 5 years ago

renevt commented 5 years ago

Please follow the guide below


Before submitting an issue, make sure you have:

Purpose of your issue?


The following sections requests more details for particular types of issues, you can remove any section (the contents between the triple ---) not applicable to your issue.


For a bug report, you must include the Python version used, code that will reproduce the error, and the error log/traceback.

Paste the output of python -V :

Code: Python 2.7.12

`` python like_hashtags.py * 2019-01-17 10:34:31,202 - INFO - Instabot Started Which account do you want to use? (Type number) 1: ** 2: **** 0: add another account. -1: delete all accounts. 2 2019-01-17 10:34:36,600 - INFO - Logged-in successfully as '*.nl' using the cookie! 2019-01-17 10:34:36,601 - INFO - Going to like media with hashtag #*****. 2019-01-17 10:34:38,642 - INFO - Going to like 77 medias. 0%| | 0/77 [00:00<?, ?it/s]2019-01-17 10:34:38,792 - ERROR - Request returns 405 error!

Media ID error! ^C Traceback (most recent call last): File "like_hashtags.py", line 27, in bot.like_hashtag(hashtag) File "/usr/lib/python2.7/site-packages/instabot/bot/bot.py", line 431, in like_hashtag return like_hashtag(self, hashtag, amount) File "/usr/lib/python2.7/site-packages/instabot/bot/bot_like.py", line 92, in like_hashtag return self.like_medias(medias) File "/usr/lib/python2.7/site-packages/instabot/bot/bot.py", line 419, in like_medias return like_medias(self, media_ids, check_media) File "/usr/lib/python2.7/site-packages/instabot/bot/bot_like.py", line 53, in like_medias self.error_delay() File "/usr/lib/python2.7/site-packages/instabot/bot/bot.py", line 272, in error_delay time.sleep(10) KeyboardInterrupt 2019-01-17 10:34:43,064 - INFO - Bot stopped. Worked: 0:04:23.970103 2019-01-17 10:34:43,065 - INFO - Total requests: 9


Describe your issue

Hi

Since a day or two i got this error, the bot wouldnt like anything anymore . Follow, unfollow ,comment and etc. works normaly.

Rouxcoucou commented 5 years ago

I have the same error since yesterday night...

stas2z commented 5 years ago

Same since yesterday evening, it stops at media_info seems like media/{id}/info api request is forbidden (405) atm

JULIANCRACK commented 5 years ago

same here since morning (paris time)

sh0ked commented 5 years ago

same here since morning (+7 UTC)

ohld commented 5 years ago

@maxdevblock @sudoguy I think we have broken something. Please check this ASAP.

maxdevblock commented 5 years ago

@maxdevblock @sudoguy I think we have broken something. Please check this ASAP.

Don't think it's an instabot issue. I got same error with older versions. Instagram has currently got an outage issue in US and EU.

ohld commented 5 years ago

Have we somehow tackle this? Maybe add some description message in instabot or some error handling to be more descriptive and less frightened?

maxdevblock commented 5 years ago

Have we somehow tackle this? Maybe add some description message in instabot or some error handling to be more descriptive and less frightened?

I'm updating users on telegram group

maxdevblock commented 5 years ago

Seems the problem is only with 'media/{media_id}/info/'.format(media_id=media_id) requests.

ohld commented 5 years ago

So what is the best way to do having this problem?

maxdevblock commented 5 years ago

Ok. Got the problem. Don't know how to solve (if we can solve or have to wait). The call 'media/{media_id}/info/'.format(media_id=media_id) is returning only

{'logged_in_user': { ALL_INFO_ABOUT_USER },
 'status': 'ok'}

but not items so the def get_media_info is failing.

maxdevblock commented 5 years ago

I'm curretly running a test every 30 min. If something changes I'll write here and in telegram

barclaey commented 5 years ago

Hi guys,

I think I found the problem.

In api.py change media_info(self, media_id) to:

    def media_info(self, media_id):
        url = 'media/{media_id}/info/'.format(media_id=media_id)
        return self.send_request(url)

That seems to do the trick.

lukasz00500 commented 5 years ago

I have The same issue, but old version of this bot work good

maxdevblock commented 5 years ago

@barclaey you're right! It works without sending json_data... :scream:

maxdevblock commented 5 years ago

@barclaey it's working. I can't get the reason why... But working! Send the pull request

silvio2810 commented 5 years ago

@maxdevblock I've tried your trick, and for me it doesn't work as well. :(

maxdevblock commented 5 years ago

@silvio2810 sent a pull req now with other fixes.

silvio2810 commented 5 years ago

@maxdevblock

def media_info(self, media_id): url = 'media/{media_id}/info/'.format(media_id=media_id) return self.send_request(url, '')

I've seen that pull, and I'm testing, but nothing!

ohld commented 5 years ago

What else can we try?

maxdevblock commented 5 years ago

@silvio2810 no... @barclaey was right return self.send_request(url) But I fixed tests too cause in tests the req was POST, now it's GET. With fixed tests, Travis doesn't fail and pull req can pass.

758

silvio2810 commented 5 years ago

I've seen the tests and the change that you made from POST to GET. I've tested it as well but nothing changed. I'm sorry to go against you @maxdevblock and @barclaey. :'(

maxdevblock commented 5 years ago

@silvio2810

It's working for me, both python2 and 3.

did u install instabot via pip or git clone?

If u installed via:

To know were your sys instabot package is, python -c "import instabot; print(instabot.__file__)"

renevt commented 5 years ago

@maxdevblock

This fix doesnt work for me either. Mabye you can help me out.

pip install instabot Requirement already satisfied: instabot in /usr/lib/python2.7/site-packages (0.4.5) Requirement already satisfied: tqdm in /usr/lib/python2.7/site-packages (from instabot) (4.28.1) Requirement already satisfied: requests-toolbelt in /usr/lib/python2.7/site-packages (from instabot) (0.8.0) Requirement already satisfied: requests in /usr/lib/python2.7/site-packages/requests-2.21.0-py2.7.egg (from instabot) (2.21.0) Requirement already satisfied: schedule in /usr/lib/python2.7/site-packages (from instabot) (0.5.0) Requirement already satisfied: future in /usr/lib/python2.7/site-packages (from instabot) (0.17.1) Requirement already satisfied: six in /usr/lib/python2.7/site-packages (from instabot) (1.12.0) Requirement already satisfied: huepy in /usr/lib/python2.7/site-packages (from instabot) (0.9.8.1) Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/lib/python2.7/site-packages/chardet-3.0.4-py2.7.egg (from requests->instabot) (3.0.4) Requirement already satisfied: idna<2.9,>=2.5 in /usr/lib/python2.7/site-packages/idna-2.8-py2.7.egg (from requests->instabot) (2.8) Requirement already satisfied: urllib3<1.25,>=1.21.1 in /usr/lib/python2.7/site-packages/urllib3-1.24.1-py2.7.egg (from requests->instabot) (1.24.1) Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python2.7/site-packages/certifi-2018.11.29-py2.7.egg (from requests->instabot) (2018.11.29)

python -c "import instabot; print(instabot.file)" /usr/lib/python2.7/site-packages/instabot/init.pyc

def remove_self_tag(self, media_id):
    data = self.json_data()
    url = 'media/{media_id}/remove/'.format(media_id=media_id)
    return self.send_request(url, data)

def media_info(self, media_id):
    url = 'media/{media_id}/info/'.format(media_id=media_id)
    return self.send_request(url)

def archive_media(self, media, undo=False):
    action = 'only_me' if not undo else 'undo_only_me'
    data = self.json_data({'media_id': media['id']})
    url = 'media/{media_id}/{action}/?media_type={media_type}'.format(
        media_id=media['id'],
        action=action,
        media_type=media['media_type']

I'm not that familair with python and linux.

Thank you

maxdevblock commented 5 years ago

@renevt are you editing /usr/lib/python2.7/site-packages/instabot/api/api.py ?

renevt commented 5 years ago

@maxdevblock hmmmz let me think im not sure let me figure it out

maxdevblock commented 5 years ago

@renevt ok try to run a script .py

from instabot import Bot

bot = Bot()
bot.login()

media_id = '1957463722880884083'
pk = bot.get_media_info(media_id)[0]['pk']
bot.logger.warn("\033[1;32m{}\033[0m".format(media_id == str(pk)))

If the green warn is True the fix is working

renevt commented 5 years ago

@maxdevblock

The cookie is not found, but don't worry instabot will create it for you using your login details. 2019-01-18 08:49:38,440 - INFO - Logged-in successfully as '***'! 2019-01-18 08:49:38,442 - INFO - Saved cookie! 2019-01-18 08:49:38,672 - WARNING - True (green ;)) 2019-01-18 08:49:38,898 - INFO - Bot stopped. Worked: 0:00:23.470825 2019-01-18 08:49:38,899 - INFO - Total requests: 4 administrator@DS216play://volume1/web$

maxdevblock commented 5 years ago

@renevt WORKING :-)

renevt commented 5 years ago

@maxdevblock 2019-01-18 08:52:20,877 - INFO - Going to like media with hashtag #****. 2019-01-18 08:52:24,068 - INFO - Going to like 81 medias. 0%| | 0/81 [00:00<?, ?it/s]2019-01-18 08:52:24,220 - ERROR - Request returns 405 error!

Media ID error! 1%|▌ | 1/81 [00:10<13:32, 10.16s/it]2019-01-18 08:52:34,377 - ERROR - Request returns 405 error!

Media ID error!

Really strange im such a noob why does it not work

maxdevblock commented 5 years ago

@renevt send me the first lines of the script you're using, from first line to bot = Bot()

renevt commented 5 years ago

@maxdevblock

im using the multi_script_CLI script for most of the times

import getpass import os import random import sys import time

from tqdm import tqdm

sys.path.append(os.path.join(sys.path[0], '../')) from instabot import Bot

bot = Bot(filter_business_accounts=False) bot.login()

Thank you

maxdevblock commented 5 years ago

@renevt ok... comment out sys.path.append(os.path.join(sys.path[0], '../')) to # sys.path.append(os.path.join(sys.path[0], '../')) this line is overriding import from system installed module and importing the local one.

renevt commented 5 years ago

@maxdevblock

No sorry i doesnt work 2019-01-18 09:05:33,979 - INFO - Instabot Started Which account do you want to use? (Type number) 1: 0: add another account. -1: delete all accounts. 1 2019-01-18 09:05:38,916 - INFO - Logged-in successfully as '**' using the cookie! 2019-01-18 09:05:38,919 - INFO - Instabot Started Which account do you want to use? (Type number) 1: ** 0: add another account. -1: delete all accounts. 1 2019-01-18 09:05:40,413 - INFO - Logged-in successfully as '***' using the cookie!

    1.Follow
    2.Like
    3.Comment
    4.Unfollow
    5.Block
    6.Setting
    7.Exit

What would you like to do? 2

    1. Like from hashtag(s)
    2. Like followers
    3. Like following
    4. Like last media likers
    5. Like our timeline
    6. Main menu

How do you want to like? 4

        1.Insert username
        2.Use username database

2 0%| | 0/43 [00:00<?, ?it/s]2019-01-18 09:05:52,392 - INFO - Liking user_196425067's feed: 2019-01-18 09:05:52,821 - INFO - Going to like 2 medias. 2019-01-18 09:05:52,972 - ERROR - Request returns 405 error! 0/2 [00:00<?, ?it/s]

Media ID error!

import getpass import os import random import sys import time

from tqdm import tqdm

sys.path.append(os.path.join(sys.path[0], '../'))

from instabot import Bot

bot = Bot(filter_business_accounts=False) bot.login()

maxdevblock commented 5 years ago

@renevt

  1. did you edit /usr/lib/python2.7/site-packages/instabot/api/api.py

    def media_info(self, media_id):
    url = 'media/{media_id}/info/'.format(media_id=media_id)
    return self.send_request(url)
  2. are you running the script with python multi_script_CLI.py or python3 multi_script_CLI.py

renevt commented 5 years ago

@maxdevblock

If you have Teamviewer and the time to help me Can you help me out with this?

Im using a synology NAS i dont know to go to /usr/lib/python2.7/site-packages/instabot/api/api.py

im using python 2

maxdevblock commented 5 years ago

@renevt to edit the file simply sudo nano /usr/lib/python2.7/site-packages/instabot/api/api.py you'll have to type your password

renevt commented 5 years ago

@maxdevblock

Thank you but the NAS is using a sort of linux so some command doesnt work . If do have really read a lot about linux. But what i try to say the nano command doesnt work. :/lib/python2.7/site-packages/instabot/api$ sudo nano /usr/lib/python2.7/site-packages/instabot/api/api.py Password: sudo: nano: command not found

but so far i have locate the api file :/lib/python2.7/site-packages/instabot/api$ ls api_photo.py api_photo.pyc api.py api.pyc api_video.py api_video.pyc config.py config.pyc devices.py devices.pyc init.py init.pyc prepare.py prepare.pyc

maxdevblock commented 5 years ago

@renevt remove your system installed instabot

pip uninstall instabot

and edit your local instabot/api/api.py as we said.

don't forget to uncomment line # sys.path.append(os.path.join(sys.path[0], '../')) to original sys.path.append(os.path.join(sys.path[0], '../')) in your multi_script_CLI.py

renevt commented 5 years ago

@maxdevblock

No i t doesnt work Max

Proceed (y/n)? administrator@DS216play:/$ pip uninstall instabot Uninstalling instabot-0.4.5: Would remove: /usr/lib/python2.7/site-packages/instabot-0.4.5-py2.7.egg-info /usr/lib/python2.7/site-packages/instabot/ Proceed (y/n)? Your response ('administrator@ds216play:/$ pip uninstall instabot') was not one of the expected responses: y, n Proceed (y/n)? Your response ('uninstalling instabot-0.4.5:') was not one of the expected responses: y, n Proceed (y/n)? Your response ('would remove:') was not one of the expected responses: y, n Proceed (y/n)? Your response ('/usr/lib/python2.7/site-packages/instabot-0.4.5-py2.7.egg-info') was not one of the expected responses: y, n Proceed (y/n)? Your response ('/usr/lib/python2.7/site-packages/instabot/') was not one of the expected responses: y, n Proceed (y/n)? Your response ('proceed (y/n)?') was not one of the expected responses: y, n Proceed (y/n)? y Exception: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/pip/_internal/cli/base_command.py", line 143, in main status = self.run(options, args) File "/usr/lib/python2.7/site-packages/pip/_internal/commands/uninstall.py", line 75, in run auto_confirm=options.yes, verbose=self.verbosity > 0, File "/usr/lib/python2.7/site-packages/pip/_internal/req/req_install.py", line 683, in uninstall uninstalled_pathset.remove(auto_confirm, verbose) File "/usr/lib/python2.7/site-packages/pip/_internal/req/req_uninstall.py", line 224, in remove renames(path, new_path) File "/usr/lib/python2.7/site-packages/pip/_internal/utils/misc.py", line 280, in renames shutil.move(old, new) File "/usr/lib/python2.7/shutil.py", line 300, in move rmtree(src) File "/usr/lib/python2.7/shutil.py", line 252, in rmtree onerror(os.remove, fullname, sys.exc_info()) File "/usr/lib/python2.7/shutil.py", line 250, in rmtree os.remove(fullname) OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/instabot-0.4.5-py2.7.egg-info/dependency_links.txt'

def media_info(self, media_id): url = 'media/{media_id}/info/'.format(media_id=media_id) return self.send_request(url)

import getpass import os import random import sys import time

from tqdm import tqdm

sys.path.append(os.path.join(sys.path[0], '../')) from instabot import Bot

bot = Bot(filter_business_accounts=False) bot.login()

Another ideas?

maxdevblock commented 5 years ago

@renevt create a new directory somewhere, cd to the dir and

git clone --single-branch --branch fix-issue-#756 https://github.com/maxdevblock/instabot.git

this will download my branch with the fix. Try the multi_script_CLI that you find there in examples folder.

kidd0ua commented 5 years ago

@maxdevblock git clone --single-branch --branch fix-issue-#756 https://github.com/maxdevblock/instabot.git it works for me. Thanks!

maxdevblock commented 5 years ago

Yeppa :-)

renevt commented 5 years ago

No @maxdevblock it downt work either im really sorry i dont know whats goes wrong im feeling such a noob ...

administrator@DS216play://bot$ git clone --single-branch --branch fix-issue-#756 https://github.com/maxdevblock/instabot.git -sh: git: command not found

administrator@DS216play://bot$ pip install instabot.git Collecting instabot.git Could not find a version that satisfies the requirement instabot.git (from versions: ) No matching distribution found for instabot.git administrator@DS216play://bot$ ls instabot.git

maxdevblock commented 5 years ago

@renevt

apt-get install git
ayush3298 commented 5 years ago

When we call check media, it sends request to 'media/{media_id}/info/'.format(media_id=media_id), but as it is returning error 405 that means the specified request HTTP method was received and recognized by the server, but the server has rejected that particular method for the requested resource. so we can guess Instagram has made some changes code is all good, but like all other endpoints, the API is working. So the temporary solution is to skip checking for media until we found any other solution.

maxdevblock commented 5 years ago

When we call check media, it sends request to 'media/{media_id}/info/'.format(media_id=media_id), but as it is returning error 405 that means the specified request HTTP method was received and recognized by the server, but the server has rejected that particular method for the requested resource. so we can guess Instagram has made some changes code is all good, but like all other endpoints, the API is working. So the temporary solution is to skip checking for media until we found any other solution.

You're right, but sending GET instead of POST actually works.

iamalminko commented 5 years ago

Thanks @maxdevblock, the fix worked for me. I'm running ubuntu 18.04, python 3.6.

renevt commented 5 years ago

@maxdevblock

Ok did the git server in the Nas

ok next problem Max

python multi_script_CLI.py Traceback (most recent call last): File "multi_script_CLI.py", line 527, in initial_checker() File "multi_script_CLI.py", line 23, in initial_checker with open(f, 'w') as f: IOError: [Errno 13] Permission denied: 'hashtagsdb.txt'

Python3 python3 multi_script_CLI.py Traceback (most recent call last): File "multi_script_CLI.py", line 7, in from tqdm import tqdm ImportError: No module named 'tqdm'

maxdevblock commented 5 years ago

@renevt

  1. for ImportError: No module named 'tqdm' go to main cloned instabot directory (cd .. from examples dir, if you're there) and
    pip install -r requirements.txt

for IOError: [Errno 13] Permission denied: 'hashtagsdb.txt' try sudo chown -R your_username:your_username * in the same directory. Obviously your_username is actually your username :-)