Answer the question
In order to leave comments, you need to log in
How to store a list of codes (links, numbers, etc.) for reading, adding a new element, searching by element in python?
Hello, please tell me how can I be?
By making a script that every hour will check for new posts in the profile, and if there is one, then through the vk api it was published in the community.
I work with insta through InstaLoader and get all the posts through the profile.get_posts() command. I receive each post in the CNrZpWTBisu format,
and then a problem arose: I cannot check the result of profile.get_posts() with my list parsed in advance.
How can I make the lists check?
import instaloader
from instaloader import Profile, Post
profile_get_posts = ['CNrZpWTBisu', 'CNm_DxEheWO', 'CNc4iMUBq0T', 'CNXD011hE6t', 'CNH8ASSBT9A', 'CM_0D-zB_iw', 'CM1dTUSB-9X', 'CMrzkvFBWSq', 'CMU0QAQqjVC', 'CMKJ0r-BjZC', 'CMB02IPh9cV', 'CL3jX1mh7uB', 'CLoMIT4hdND']
# метод проверки наличия новых постов
def scrapImageAddresses(user_id):
profile = Profile.from_username(loader.context, "user_id")
with open('posted_posts.txt', 'r') as file:
for post in profile_get_posts:
post = str(post)
print(111111, post)
if post not in file:
print(f'{post} этого поста нет')
# file_text.insert(0, f'{post_shortcode}\n')
# with open('posted_posts.txt', 'w') as file:
# file.writelines(file_text)
# Тут этот цикл заканчивается и делает return
return post
elif post in file: print('Это старый пост')
return False #Если новых постов вообще нет
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question