Kirti Palve
Kirti Palve

Reputation: 21

"Cannot detect post media type. Skip" InstaPy bot doesn't interact with posts

I am trying to write a code for instapy to like and comment on posts through tags. It shows up the tags page but does not interact with the posts. My code:

session = InstaPy(username, password)                               
session.login()                                                                          
session.set_relationship_bounds(enabled=True,max_followers=200)                          
session.set_do_follow(True,percentage=100)                                               
session.like_by_tags(["indiemusic", "heartbreakanniversary"], amount=5,interact=True)      
session.set_dont_like(["naked", "nsfw"])                                                 
session.set_do_follow(True, percentage=50)                                               
session.set_do_comment(True, percentage=50)                                              
session.set_comments(["Nice!", "S`weet!", "Beautiful :heart_eyes:"])                      
session.set_user_interact(amount=1,randomize=True,percentage=100)                        
session.end()                                                                                         

Upvotes: 1

Views: 7072

Answers (2)

Anil Chhetri
Anil Chhetri

Reputation: 1

Here's what I did. First, download the latest version of instapy or upgrade it. https://github.com/timgrossmann/InstaPy

Second, check all the recent changes in the file if it matches your local instapy from here.

https://github.com/timgrossmann/InstaPy/pull/6195/files/898f80175a5aaf8298dafdf82b5a70a34d443bf1?file-filters%5B%5D=#R97

And last not the list Change span ----> div in these 2

  1. "//a[@href='/p/" + post_href.split("/")[-2] + "/']/child::div"

    • "/']/child::div[@class='u7YqG']/child::div"

make these two changes in the like_util.py in line 900 around on your local instapy packages.

After doing this it works perfectly on the date 29/08/2021

It was a tedious process but worth it.

Upvotes: 0

guttikar
guttikar

Reputation: 71

There is a single word bug in the like_util.py file. It has been submitted as a bug and a merge request has been made. So at some point in the future, you can just reinstall InstaPy and it will get fixed.

In the meantime, if you still want to use the package, you have multiple options:

  1. Find the like_util.py file on your system and change the last "span" to "div" on line 908. See here. You can find the possible directories in which instapy will be installed by running the following commands in a python shell.

    import sys; print(sys.path)

This prints a list of paths. On my system instapy is in a directory called site-packages/instapy in one of those paths.

  1. Use virtual environment and install instapy in it and then modify the file like_util.py file there. Instructions for this can be found in the additional information tab of the instapy.org documentation site.

Upvotes: 6

Related Questions