我一直在毫无问题地运行 Instapy,其他功能,如取消关注、关注和观看故事和卷轴都仍然有效。我遇到的问题是标签喜欢。我得到的错误信息是
Traceback (most recent call last):
File "/Users/em/PycharmProjects/instabot_1/test_1_likes.py", line 61, in <module>
session.like_by_tags(random.sample(like_tag_list, 3),
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/instapy/instapy.py", line 1977, in like_by_tags
inappropriate, user_name, is_video, reason, scope = check_link(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/instapy/like_util.py", line 618, in check_link
media = post_page[0]["shortcode_media"]
KeyError: 0
我正在通过 Firefox、Pycharm 运行 Instapy,并且我使用的是 Mac。我是 Python 的新手。
这是我正在运行的代码...
import random
from instapy import InstaPy
from instapy import smart_run
browser = r'C:\Program Files\Mozilla Firefox\firefox.exe'
# login credentials
insta_username = 'myaccountname'
insta_password = 'mypassword'
dont_likes = ['sex', 'nude', 'naked', 'beef', 'pork', 'seafood',
'egg', 'chicken', 'cheese', 'sausage', 'lobster',
'fisch', 'schwein', 'lamm', 'rind', 'kuh', 'meeresfrüchte',
'schaf', 'ziege', 'hummer', 'yoghurt', 'joghurt', 'dairy',
'meal', 'food', 'eat', 'pancake', 'cake', 'dessert',
'protein', 'essen', 'mahl', 'breakfast', 'lunch',
'dinner', 'turkey', 'truthahn', 'plate', 'bacon',
'sushi', 'burger', 'salmon', 'shrimp', 'steak',
'schnitzel', 'goat', 'oxtail', 'mayo', 'fur', 'leather',
'cream', 'hunt', 'gun', 'shoot', 'slaughter', 'pussy',
'breakfast', 'dinner', 'lunch']
#friends = ['list of friends I do not want to interact with']
like_tag_list = ['vegan', 'veganfoodshare', 'veganfood', 'whatveganseat',
'veganfoodie', 'veganism', 'govegan',
'veganism', 'vegansofig', 'veganfoodshare', 'veganfit',
'veggies']
# prevent posts that contain some plantbased meat from being skipped
ignore_list = ['vegan', 'veggie', 'plantbased']
accounts = ['accounts with similar content']
# get a session!
session = InstaPy(username=insta_username,
password=insta_password,
headless_browser=True)
with smart_run(session):
# settings
session.set_relationship_bounds(enabled=True,
max_followers=15000)
#session.set_dont_include(friends)
session.set_dont_like(dont_likes)
session.set_ignore_if_contains(ignore_list)
session.set_user_interact(amount=2, randomize=True, percentage=60)
session.set_do_follow(enabled=True, percentage=40)
session.set_do_like(enabled=True, percentage=80)
# activity
session.like_by_tags(random.sample(like_tag_list, 3),
amount=random.randint(50, 100), interact=True)
session.unfollow_users(amount=random.randint(75, 150),
InstapyFollowed=(True, "all"), style="FIFO",
unfollow_after=90 * 60 * 60, sleep_delay=501)
session.end()