コード例 #1
0
def instaPostDownloader():

    shortcode = (request.data.decode().split(sep='/'))[4]

    try:
        #Post instances
        post = Post.from_shortcode(L.context, shortcode)
        #result list
        posts = []

        if (post.mediacount > 1):
            for i, j in zip(range(post.mediacount), post.get_sidecar_nodes()):
                if (j.is_video):
                    posts.append(j.video_url)
                else:
                    posts.append(j.display_url)
        else:
            if (post.is_video):
                posts.append(post.video_url)
            else:
                posts.append(post.url)

        return jsonify({'Username': post.owner_username, 'posts': posts})

    except Exception as exp:
        return jsonify({'Error': f'{exp}'})
コード例 #2
0
ファイル: finder.py プロジェクト: Sharfik69/instaDownloader
def load_photo_from_post(short_code):
    L = Instaloader(download_pictures=False,
                    download_comments=False,
                    compress_json=False,
                    download_videos=True)
    try:
        post = Post.from_shortcode(L.context, short_code)
    except Exception:
        return {'status': 'bad'}
    L.download_post(post, target=short_code)

    super_json = glob.glob(short_code + '/*.json')[0]

    response = {}
    super_dict = json.loads(open(super_json).read())

    if 'edge_sidecar_to_children' in super_dict['node']:
        response['img'] = []
        for i in super_dict['node']['edge_sidecar_to_children']['edges']:
            response['img'].append(i['node']['display_resources'])
    else:
        response['img'] = [super_dict['node']['display_resources']]

    response['owner'] = super_dict['node']['owner']
    response['status'] = 'ok'
    shutil.rmtree(short_code)
    return response
コード例 #3
0
def getComments():
    # print("This function will get comments")

    global btn_getRandom
    global label
    global usernames

    L = instaloader.Instaloader()
    post = Post.from_shortcode(L.context, 'CDjK4YqA5r6')
    usernames = list(set([comment.owner.username for comment in post.get_comments()]))

    #shuffling the list randomly
    random.shuffle(usernames)

    btn_getInfo.destroy()

    btn_getRandom = Button(canvas, text = "Randomly Select a Winner", font=("Helvetica", 12), command=selectWinner)
    canvas.create_window(250,200,window=btn_getRandom)
    label = Label(text = "Winner will be displayed here", font=("Helvetica", 12))
    canvas.create_window(250,270,window=label)

    #let me remove my own account from the list :
    usernames.remove("femindharamshi")
    usernames.remove("beyondhelloworld")

    for user in sorted(usernames):
        print(user)
コード例 #4
0
async def menu(message: types.Message):
    global user, userid, profile
    row = db.execute_one_query(
        conn, f'SELECT * FROM users WHERE user_id = "{message.from_user.id}"')
    msg = message.text
    if '/s/' in msg:
        await message.reply(key[row[1]][12])
    elif 'instagram.com/p/' in msg:
        SHORTCODE = msg.split('/p/')[1].split('/?')[0]
        post = Post.from_shortcode(L.context, SHORTCODE)
        if post.owner_profile.is_private == True:
            await message.reply(key[row[1]][1])
        else:
            await post_downloader(message, post=post)
    elif 'instagram.com/' in msg:
        user = msg.split('.com/')[1][0:-1]
        if '?' in msg: user = msg.split('.com/')[1].split('?')[0]
        profile = Profile.from_username(L.context, user)
        userid = profile.userid
        print(userid)
        if profile.is_private == True:
            await message.reply(key[row[1]][1])
        else:
            await post_downloader(message, posts=1)
    else:
        try:
            msg = msg.replace('@', '')
            profile = Profile.from_username(L.context, msg)
            userid = profile.userid
            if profile.is_private == True:
                await message.reply(key[row[1]][1])
            else:
                await post_downloader(message, posts=1)
        except:
            await message.reply(key[row[1]][2])
コード例 #5
0
def Main_Ting():

    L = instaloader.Instaloader()

    USER = str(
        pd.read_csv("Instagram_accounts.csv")
        ["AdminFollowing_Bot_Username"].iloc[0])
    PASSWORD = str(
        pd.read_csv("Instagram_accounts.csv")
        ["AdminFollowing_Bot_Password"].iloc[0])
    L.login(USER, PASSWORD)

    df1 = pd.read_csv(
        "Group_1/Leeching_Bot/Links_That_Need_To_Give_Engagment.csv")
    #df1["Links"].iloc[0]
    post = Post.from_shortcode(L.context, str(df1["Links"].iloc[0]))
    Username_Of_Owner = post.owner_username

    Following = instaloader.Profile.from_username(
        L.context, Username_Of_Owner).get_followees()
    df2 = pd.read_csv("Group_1/Group1_Admins_IG.csv", skiprows=1)["UserNames"]

    Num_Of_Admins_Following = 0
    Num_Of_Admins_Not_Following = 0
    Num_Of_Admins_Usernames = len(df2)
    Reminder_Messages_Sent = 0
    Comment_Checker_Activated = 0  #Stops the comment checker to run more than once

    for i in Following:

        for x in df2:

            if str(x)[1:] in str(i):
                Num_Of_Admins_Following += 1

            elif Num_Of_Admins_Following == Num_Of_Admins_Usernames and Comment_Checker_Activated == 0:  #Checks their link becuase they are following all admins
                Comment_Checker_Activated += 1

                import Group_1.Leeching_Bot.Like_Checker as Like_Checker
                Like_Checker.Main_Ting()

                import Group_1.Leeching_Bot.Comment_Checker as Comment_Checker
                Comment_Checker.Main_Ting()

            elif Num_Of_Admins_Not_Following > 0 and Reminder_Messages_Sent == 0 and Comment_Checker_Activated == 0:  #Remind the user privately that they need to follow all admins
                Reminder_Messages_Sent += 1
                Bot_With_Token = telegram.Bot(
                    token=pd.read_csv("Group_1/Group1_Global_Settings.csv")
                    ["Leeching_Bot_Key"].iloc[0])
                Bot_With_Token.sendMessage(
                    chat_id=str(df1["Link_User_Id"].iloc[0]),
                    text=
                    "@{} You MUST follow all the admins on Instagram before posting a link"
                    .format(df1["User_Name"].iloc[0]))
                Bot_With_Token.sendMessage(
                    chat_id=str(df1["Link_User_Id"].iloc[0]),
                    text="{}".format(df2.to_string(
                        header=False, index=False)))  #TEST THISSSSSSSSSS
            else:  #Runs when they are not folowing a admin
                Num_Of_Admins_Not_Following += 1
コード例 #6
0
def get_post_likers(shortcode, loader):
    try:
        post = Post.from_shortcode(loader.context, shortcode)
    except KeyError as e:
        logger.exception(f"Exception details: {e}")
        logger.error(f"HUMAN READABLE ERROR LOG:\n\
                Could not create post from shortcode '{shortcode}'.\n\
                Make sure:\n\t-the post is not deleted and \n\t-there is no typo in the shortcode \n then try again"
                     )
        sys.exit("Exited 1")

    except instaloader.QueryReturnedBadRequestException as e:
        remove_file(SESSION_FILE)
        logger.exception(f"Exception details: {e}")
        logger.error(f"HUMAN READABLE ERROR LOG:\n\
                Well, I guess Instagram limited the Account '{USERNAME} again.\n\
                Solve the captcha from instagram web and make sure the password is correct.\n\
                If the problem persisted remove session file '{SESSION_FILE}'."
                     )

        telegram_send(
            TELEGRAM_ID, "Account limited",
            f"Account {USERNAME} was limited while fetching {HASHTAG} posts,\
                               solve captcha and and run the code again. it will resume automatically"
        )

        sys.exit("DO ABOVE ADN RUN AGIAN.\nEXITED 1")

    post_likers = []
    for liker_profile in post.get_likes():
        post_likers.append(liker_profile.username.lower())

    return post_likers
コード例 #7
0
def get_media_details(link):
    shortcode = link.split('/p/')[1].replace('/', '')
    post = Post.from_shortcode(L.context, shortcode)
    owner_profile = post.owner_profile

    full_name = owner_profile.full_name
    followers = owner_profile.followers
    followees = owner_profile.followees
    is_verified = owner_profile.is_verified
    is_private = owner_profile.is_private
    bio = owner_profile.biography
    external_url = owner_profile.external_url

    owner_username = post.owner_username
    url = post.url
    caption = post.caption
    caption_hashtags = post.caption_hashtags
    if len(caption_hashtags) == 0:
        caption_hashtags = None
    caption_mentions = post.caption_mentions
    if len(caption_mentions) == 0:
        caption_mentions = None
    is_video = post.is_video
    video_url = post.video_url
    if (is_video):
        media_url = video_url
    else:
        media_url = url
    likes = post.likes
    comments = post.comments
    return (full_name, followers, followees, is_verified, is_private, bio,
            external_url, owner_username, url, caption, caption_hashtags,
            caption_mentions, is_video, media_url, likes, comments)
コード例 #8
0
def save_content(user: Member, post: instaloader.Post) -> Feed or None:
    ig = Feed.objects.instagram_v2().filter(status_id=post.shortcode).first()
    if ig:
        return ig

    profile = post.owner_profile
    created_at = post.date.replace(tzinfo=timezone.utc)

    # handle caption
    caption = ''
    if post.caption is not None:
        caption = post.caption
    ig = Feed.objects.create(author=profile.username, created_at=created_at, title=caption, user=user,
                             type='instagram_v2', status_id=post.shortcode,
                             link=f'https://www.instagram.com/p/{post.shortcode}')

    # Only an image
    if post.typename == 'GraphImage':
        m = Media.objects.create(feed=ig, original_url=post.url)
        async_task(m.download_to_local)

    # Multi images
    elif post.typename == 'GraphSidecar':
        for image in post.get_sidecar_nodes():
            m = Media.objects.create(feed=ig, original_url=image.display_url)
            async_task(m.download_to_local)

    elif post.typename == 'GraphVideo':
        ig.is_video = True
        ig.save(update_fields=['is_video'])
        m = Media.objects.create(feed=ig, original_url=post.url, )

    logger.info(f'Instagram: {ig} saved')
    return ig
def download_photos(username):
    L = Instaloader(download_videos = False, download_video_thumbnails = False, download_comments = False, compress_json = False, dirname_pattern = "../Data/Photos/{target}")

    posts = []
    with open("../Data/Posts_list/" + username + ".json") as f:
        posts = json.load(f)

    for post in posts:
        post = Post.from_shortcode(L.context, post)
        L.download_post(post, username)
コード例 #10
0
def download_insta_picture_from_post(url):
    shortcode = url.split("/")[-2]
    L = instaloader.Instaloader()
    post = Post.from_shortcode(L.context, shortcode)
    response = requests.get(post.url)

    if post.is_video:
        raise Exception('This post is a video, it will not be downloaded')

    return response.content
コード例 #11
0
def users_list_from_post_shortcode_list(post_shortcode_list):
        print("Importing <1000 usernames for each post")
	likers=[]
	for shortcode in post_shortcode_list:
		post = Post.from_shortcode(L.context, shortcode)
		for liker in post.get_likes():
       			likers.append(liker.username)
			print(len(likers))
			if len(likers) == 999:
				break
	return likers
コード例 #12
0
def get_insta_links(url):
    try:
        shortcode = get_insta_shortcode(url)

        post = Post.from_shortcode(L.context, shortcode)

        return True, post

    except Exception as e:
        print(str(e))
        return False, []
コード例 #13
0
ファイル: insta.py プロジェクト: dino-inc/dinobotextras
async def instagram_rip(self, shortcode, message):
    try:
        async with message.channel.typing():
            post = Post.from_shortcode(self.insta.context, shortcode.group(2))
            self.insta.download_post(post, "instagram")
            return True
    except TypeError:
        return False
    except Exception as e:
        await message.channel.send(f"Unable to download instagram post; error is {e}")
        return False
コード例 #14
0
 def downloadMetadata(self):
     """Downloads metadata of this post to the database"""
     L = self.__startInstaloaderInstance()
     shortcode = self.metadata['photo_url'].split('/')[-2]
     profile = Profile.from_username(L.context,
                                     self.metadata['photographer_name'])
     post = Post.from_shortcode(L.context, shortcode)
     data_profile = profile._asdict(
     )  # accessing the metadata dict from the profile structure, UGLY
     data_post = post._asdict(
     )  # accessing the metadata dict from the post structure, UGLY
     metadata = {}
     metadata['photo_url'] = self.metadata['photo_url']
     metadata['likes'] = post.likes
     ## TOO LONG STILL
     timestamp = str(data_post['taken_at_timestamp'])
     timetaken = datetime.datetime.fromtimestamp(
         int(timestamp)).strftime('%Y-%m-%d %H:%M:%S')
     datetimeFormat = '%Y-%m-%d %H:%M:%S'
     postdate = datetime.datetime.strptime(timetaken, datetimeFormat)
     time_now = datetime.datetime.now()
     dt = time_now - postdate
     TimeDifferenceInHours = dt.total_seconds() / 3600.0
     TimeDifferenceInDays = TimeDifferenceInHours / 24.0
     TimeDifferenceInDays = round(TimeDifferenceInDays, 2)
     metadata['age'] = TimeDifferenceInDays
     ## TOO LONG STILL
     metadata['downloaded'] = str(datetime.datetime.now())
     # get image descriptions
     try:
         metadata['IG_category'] = \
         data_post['edge_sidecar_to_children']['edges'][0]['node']['accessibility_caption'].split(
             'Image may contain:')[1].split("\n")[0]
     except:
         metadata['IG_category'] = ''
     hashtags_original = post.caption_hashtags  # reformating into one string with '#' in front
     if not hashtags_original:
         hashtags_original = self.scanCommentsForHashtags(data_post)
     hashtags = []
     if hashtags_original:
         for tags in hashtags_original:
             hashtags.append('#' + tags)
     hashtags_str = str(hashtags).replace(",", "").replace("'", "").replace(
         "[", "").replace("]", "")
     metadata['hashtags'] = hashtags_str
     metadata['photographer_name'] = data_post['owner']['username']
     metadata['followers'] = data_post['owner']['edge_followed_by']['count']
     metadata['following'] = data_profile['edge_follow']['count']
     metadata['photo_name'] = shortcode
     metadata[
         'is_downloaded'] = True  # this method is only used for saved posts
     self.metadata = metadata
     print('|    Metadata was scrapped')
     return metadata
コード例 #15
0
ファイル: bot.py プロジェクト: tlaskyd/tlaskyinsta
 def like_post(self):
     shortcode = list(self.posts).pop(0)
     post = Post.from_shortcode(self.context, shortcode)
     self.logger.info(
         f'Liking {post_url(post)} by {post.owner_username} ({len(self.posts)})'
     )
     if not self.insta.like_post(post).viewer_has_liked:
         self.logger.warning(
             'Liking is probably banned, removing session file')
         os.remove(self.session_file)
         raise BotExitException()
     self.posts.remove(shortcode)
コード例 #16
0
ファイル: update_db.py プロジェクト: Likbjorn/instamonitor
def update_likes_all_posts(context: InstaloaderContext):
    """
    Run 'update_post_likes' for all posts in db
    :return: None
    """
    sql = "SELECT mediaid FROM posts"
    with sqlite3.connect(DB_LOCATION) as conn:
        cursor = conn.cursor()
        cursor.execute(sql)
        media_ids = cursor.fetchall()
    for mediaid in media_ids:
        post = Post.from_mediaid(context, mediaid[0])
        update_likes(post)
コード例 #17
0
ファイル: cleaner.py プロジェクト: DemianMelskens/CBS
def get_posts(urls):
    posts_dict = {}
    L = instaloader.Instaloader()
    for index, url in enumerate(urls):
        shortcode = url.split("/")[-2]

        # time.sleep(0.1)
        try:
            post = Post.from_shortcode(L.context, url.split("/")[-2])
            posts_dict[shortcode] = post
        except:
            pass

    return posts_dict
コード例 #18
0
def get_insta_links(L: Instaloader, url: str) -> tuple:
    """
    Return list of shortcodes
    :param url: URL
    :return: success status and list of shortcodes
    """
    try:
        shortcode = get_insta_shortcode(url)

        post = Post.from_shortcode(L.context, shortcode)

        return True, post

    except Exception as e:
        print(str(e))
        return False, []
コード例 #19
0
 def downloadPic(self):
     """Downloads the jpg of this post (or all jpgs, if multiimage)
     to a folder named by the Instagram User
     Returns a True flag if image was saved
     Since this flag is not 100% reliable, this is complemented by the confirmPresenceOfJpg(self) method"""
     L = self.__startInstaloaderInstance()
     shortcode = self.metadata['photo_url'].split('/')[-2]
     profile = Profile.from_username(L.context,
                                     self.metadata['photographer_name'])
     post = Post.from_shortcode(L.context, shortcode)
     if post.is_video:
         self.postIsVideo = True
     picture_save_flag = L.download_post(
         post,
         target='DB' + profile.username,
     )
     return picture_save_flag
コード例 #20
0
def saveImageFromIG(url, templateName):
    shortedUrl = url.split('/')[4]
    print(shortedUrl)
    print(os.getcwd())
    i = instaloader.Instaloader()
    print(os.getcwd())
    post = Post.from_shortcode(i.context, shortedUrl)
    os.chdir('E:/Animatedtimes/Meme Maker Automation/V2')
    i.download_post(post, target='postIG')
    deleteALlTXT()
    os.chdir('postIG')
    webImage = os.listdir()
    for i in range(len(webImage)):
        os.chdir('../postIG')
        makeMemeWebImage(webImage[i], templateName)
        os.chdir('../postIG')
        os.remove(webImage[i])
コード例 #21
0
ファイル: update_db.py プロジェクト: Likbjorn/instamonitor
def update_likes(post: Post):
    """
    Scrape profiles who likes given post and put to db
    :param post: instaloader.Post instance
    :return: None
    """
    # TODO: use batches to update
    sql = "INSERT INTO likes (mediaid, userid, scrape_datetime) VALUES (?, ?, ?);"
    with sqlite3.connect(DB_LOCATION) as conn:
        cursor = conn.cursor()
        likes = post.get_likes()
        for like in likes:
            logging.debug(
                f"Scraped like from {like.username} for {post.profile}'s "
                f"post with id {post.mediaid}")
            date = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")
            cursor.execute(sql, (post.mediaid, like.userid, date))
    logging.info("Table 'likes' is updated")
コード例 #22
0
ファイル: downloader.py プロジェクト: DemianMelskens/CBS
def download_insta_picture_from_post(url, download_path):
    try:
        shortcode = url.split("/")[-2]
        L = instaloader.Instaloader()
        post = Post.from_shortcode(L.context, shortcode)
        response = requests.get(post.url)
        filename = shortcode + '.jpg'
        path = download_path + filename

        if post.is_video:
            print('Post skipped because its a video', url)
            return False

        with open(path, "wb") as handle:
            for data in tqdm(response.iter_content()):
                handle.write(data)

        return True
    except:
        print('Could not download file', sys.exc_info()[0], url)
        return False
コード例 #23
0
def get_comments(post, skip_author, comment_text):
    L = Instaloader()
    post = Post.from_shortcode(L.context, post)
    owner_username = post.owner_username
    comments = []
    for comment in post.get_comments():
        if skip_author and owner_username == comment.owner.username:
            continue
        if comment_text:
            next_word = False
            for word in comment_text.split(','):
                if word not in comment.text:
                    next_word = True
            if next_word:
                continue
        comments.append({
            'username': comment.owner.username,
            'created_at': str(comment.created_at_utc),
            'text': comment.text
        })
    logging.info(f'Downloaded {len(comments)} comments')
    return comments
コード例 #24
0
def is_shadowbaned(shortcode):
    L = Instaloader()
    POST = Post.from_shortcode(L.context, shortcode)
    DATE = POST.date
    #TODO regex from Link to get Shortcode
    DATE = POST.date
    hashtags_list = gh.get_hashtags(POST)
    shadow = False
    print(hashtags_list)
    for h in hashtags_list:
        count = 0
        #status
        print('analizando', h)
        H = Hashtag.from_name(L.context, h)
        if shadow == True:
            break
        #This K is to work with uncronological random posts
        k = 0
        #get the posts from the hashtag
        posts = H.get_posts()
        k_list = []  #----debug
        for p in posts:
            count += 1
            postdate = p.date
            if p == POST:
                print(h, 'funded in', count)
                print('_____________________')
                break
            if postdate <= DATE:
                k += 1
                k_list.append(k)  #--debug
                #accept until 300 uncronological random posts
                if k == 300:
                    shadow = True
                    print(h, 'baneado')
                    break
                else:
                    continue
コード例 #25
0
ファイル: is_top.py プロジェクト: e2tovar/instatools
import get_post_hashtags as gh
from instaloader import Instaloader, Post, Hashtag


def is_top(hashtags_list):
    for h in hashtags_list:
        count = 0
        #status
        print('analyzing', h)
        H = Hashtag.from_name(L.context, h)

        #get the top posts from the hashtag
        top_posts = H.get_top_posts()
        for tp in top_posts:
            count += 1
            if tp == POST:
                print(h, 'funded in', count)
                break
        print('-----------------------------------')


if __name__ == '__main__':
    L = Instaloader()
    print('Paste the post link here:')
    SHORTCODE = input()
    POST = Post.from_shortcode(L.context, SHORTCODE)
    is_top(gh.get_hashtags(POST))
コード例 #26
0
ファイル: instadl.py プロジェクト: ayay182/xdecha
def get_post(client: Instaloader, shortcode: str) -> Post:
    """ returns a post object """
    return Post.from_shortcode(client.context, shortcode)
コード例 #27
0
    ids_list = f.read()
    ids_list = ids_list.split('\n')

L = Instaloader()

for username in ids_list:
    print("Downloading data for :", username)

    post_likes = {}

    data_dir = os.path.join("data", "raw", username)
    ce_files_lst = glob.glob(os.path.join(data_dir, "*.txt"))

    for ce_file in tqdm(ce_files_lst):
        try:
            post_shortcode = re.sub(data_dir + '/', '',
                                    os.path.splitext(ce_file)[0])

            post = Post.from_shortcode(L.context, post_shortcode)
            profiles_that_liked_post = []

            for profile in post.get_likes():
                profiles_that_liked_post.append(profile.userid)

            post_likes[post_shortcode] = profiles_that_liked_post
        except Exception:
            continue

    with open(data_dir + "-likes.p", 'wb') as handle:
        pickle.dump(post_likes, handle, protocol=pickle.HIGHEST_PROTOCOL)
コード例 #28
0
    def get_post_from_shortcode(self, SHORTCODE: str, MAX_COMMENT: int):
        post = Post.from_shortcode(self.L.context, SHORTCODE)
        try:
            accessibility_caption = str(
                post._asdict()['accessibility_caption'])
        except Exception as ex:
            print(ex)
        try:
            location = post.location
        except Exception as ex:
            print(ex)
            location = None
            #INFORMATION OF THE POST GOING INTO THE CSV
            post_info_dict = {
                'title': post.title,
                'owner_username': post.owner_username,
                'date_and_time': post.date,
                'type_of_post': post.typename,
                'mediacount': post.mediacount,
                'caption': post.caption,
                'n_caption_hashatags': len(post.caption_hashtags),
                'caption_hashtags': post.caption_hashtags,
                'n_mentions_post': len(post.caption_mentions),
                'n_tagged_users': len(post.tagged_users),
                'is_video': post.is_video,
                'n_likes': post.likes,
                'n_comments': post.comments,
                'is_sponsored': post.is_sponsored,
                'sponsors': post.sponsor_users,
                'location': location,
                'url_link': post.url,
                'url_insta': 'instagram.com/p/{}/'.format(post.shortcode),
                'description_of_post': accessibility_caption,
            }
            comments_vect = []
            # DOWNLOAD AND STORE COMMENT
            print('Start Comments', end='')

            comment_count = 0
            for comment in post.get_comments():
                answer_count = 0
                for answer in comment.answers:
                    answer_count += 1
                    if answer_count == 50:
                        break
                analisys, score = self.analizer.return_sentiment(
                    str(comment.text).strip())
                comment_info_dict = {
                    'date_and_time': comment.created_at_utc,
                    'profile': comment.owner.username,
                    'text': str(comment.text).strip(),
                    'n_likes': comment.likes_count,
                    'answer_count': answer_count,
                    'sentiment_analysis': analisys,
                    'score': score
                }

                comments_vect.append(comment_info_dict)
                if comment_count == MAX_COMMENT:
                    break
                comment_count += 1
                print('.', end='')
            print('End Comments')
            comment_df = pd.DataFrame(comments_vect)
            post_df = pd.DataFrame([post_info_dict])

            return post_df, comment_df
コード例 #29
0
        description="Get images from the specified Instagram post.",
        guild_ids=hkd.get_all_guild_ids(),
        options=[
            create_option(name="url",
                          description="URL of the Instagram post.",
                          option_type=3,
                          required=True)
        ])
    @commands.cooldown(1, 10, BucketType.guild)
    async def instapics(self, ctx: SlashContext, url: str):
        await ctx.defer()
        if not ((shortcode := hkd.get_id_from_url(url, '/p/', '/')) or
                (shortcode := hkd.get_id_from_url(url, '/reel/', '/'))):
            return
        images, videos = [], []
        post = Post.from_shortcode(self.insta_api.context, shortcode)
        if post.typename == 'GraphSidecar':
            for node in post.get_sidecar_nodes():
                if node.is_video:
                    videos.append(node.video_url)
                else:
                    images.append(node.display_url)
        elif post.typename == 'GraphImage':
            images.append(post.url)
        elif post.typename == 'GraphVideo':
            videos.append(post.video_url)
        await hkd.send_content_with_delay(ctx, images)
        await hkd.send_content_with_delay(ctx, videos)

    @cog_ext.cog_slash(
        description="Get images from the specified Ameba blog post.",
コード例 #30
0
from datetime import time


#LOGIN INSTABOT#
bot = instabot.Bot()
bot.login(username = "******", password = "******")

#LOGIN INSTALOADER#
L = instaloader.Instaloader()
L.login("patagonian_review","Comandos1")

#Creo objeto de clase Profile#
profile=Profile.from_username(L.context,"igalkej")

#Creo objeto de clase Post#
post = Post.from_shortcode(L.context, "Bh1wRc9Ha9VwwsHAFcHP-viJuh-favoZw0BB4U0")

#Get followees from profile#
print("{} follows these profiles:".format(profile.username))
for followee in profile.get_followees():
    print(followee.username)


#Get usernames for hashtaf


def users_list_from_hashtags(hashtags):
	print("Importing ~ 85 usernames for each hashtag")
	hashtag_users = []
	hashtag_usernames = []