无需在 python 中登录即可从 Instagram 下载图像

问题描述 投票:0回答:0

我正在建设一些项目,我需要从 instagram 下载一些图片。 问题是 instagram 不允许我登录。每次我想登录时都需要通过我的手机进行验证。

我需要登录/下载特定页面的最后一张图片 而且该项目并没有那么大,无法为 Instagram API 付费。

如果您知道这样做的方法,我很乐意听取您的建议。 另外,如果您认为使用另一种语言或框架更容易做到这一点,请与我分享。

我使用了 Instaloader 库,但正如我所说,它没有登录。

import instaloader

# Create an instance of the instaloader class
L = instaloader.Instaloader()

# Login to your Instagram account
username = "clancy"
password = "password"
L.context.log("Logging in...")
L.interactive_login(username)
# L.load_session_from_file(username)
if not L.context.is_logged_in:
    L.context.log("Login required")
    L.interactive_login(username)

# Load the profile by its name
profile = instaloader.Profile.from_username(L.context, 'ycnalc')

# Get the latest post
post = profile.get_posts()[0]

# Download the post
L.download_post(post, target='C:\\Users\\Achak\\Documents\\GitHub\\typhoone\\EXPERIMENTS')
python web-scraping instagram instaloader
© www.soinside.com 2019 - 2024. All rights reserved.