![aa908f06c125e1a37265ea0e304afacf.png](https://i-blog.csdnimg.cn/blog_migrate/6af5716290e2e8a16bf1b0b4f30ce2f9.jpeg)
相信很多人都会刷Instagram,当你看到漂亮的小姐姐,喜欢的Po主,总会忍不住想要把图片下载下来,我之前用的是手机上的APP插件,只要复制网页链接到下载APP内,就会自动将这条帖子的所有图片视频保存下来,但是始终不够方便。
如果你想批量下载指定用户的图片时,可能就比较麻烦。我一开始以为谷歌插件会支持这个功能,于是使用了如下谷歌商店的插件。
https://chrome.google.com/webstore/detail/downloader-for-instagram/olkpikmlhoaojbbmmpejnimiglejmboechrome.google.com他比手机上使用更加方便,当在PC端刷Instagram时,只要点击图片左上角download即可使用。
![542b52d9c9ee119881a2c7ce338bf091.png](https://i-blog.csdnimg.cn/blog_migrate/664aa84858ea79eb3e352dc17444a7ac.jpeg)
![72c4dd44828f591b338a898845529beb.png](https://i-blog.csdnimg.cn/blog_migrate/6a4d0b164db019d04f3eb343a5950715.jpeg)
涉及到单张图片下载时,还比较方便,但批量下载功能只支持用户主页的第一张图片,
![ba82b0145d89a79e3c20c6733b3a1dc9.png](https://i-blog.csdnimg.cn/blog_migrate/80b0c36a8fb3c4d2374912c24212d07d.jpeg)
于是我就尝试搜索instagram批量下载功能,在github发现了如下项目:
https://github.com/rarcega/instagram-scrapergithub.cominstagram-scraper是用Python编写的命令行应用程序,可抓取并下载instagram用户的照片和视频。
安装
要安装instagram-scraper:只需要在控制台中运行如下命令
pip install instagram-scraper
个人用户登录(也可以不登录)
instagram-scraper <username> -u <your username> -p <your password>
爬取图片:
instagram-scraper username1,username2,username3
![1496bee05a53c32e830c00c35605b026.png](https://i-blog.csdnimg.cn/blog_migrate/adf624f2c0d1aa8d0bfb649a74402700.png)
当全部图片下载完以后,就可以在自己的个人用户目录下,找到爬取用户的文件夹,里面所有的照片和视频就都保存下来了。通过这个方法,可以爬取很多自己喜欢的明星、博主、小姐姐照片。
其他:
--help -h Show help message and exit.
--login-user -u Instagram login user.
--login-pass -p Instagram login password.
--followings-input Use profiles followed by login-user as input
--followings-output Output profiles from --followings-input to file
--filename -f Path to a file containing a list of users to scrape.
--destination -d Specify the download destination. By default, media will
be downloaded to <current working directory>/<username>.
--retain-username -n Creates a username subdirectory when the destination flag is
set.
--media-types -t Specify media types to scrape. Enter as space separated values.
Valid values are image, video, story (story-image & story-video),
or none. Stories require a --login-user and --login-pass to be defined.
--latest Scrape only new media since the last scrape. Uses the last modified
time of the latest media item in the destination directory to compare.
--latest-stamps Specify a file to save the timestamps of latest media scraped by user.
This works similarly to `--latest` except the file specified by
`--latest-stamps` will store the last modified time instead of using
timestamps of media items in the destination directory.
This allows the destination directories to be emptied whilst
still maintaining history.
--cookiejar File in which to store cookies so that they can be reused between runs.
--quiet -q Be quiet while scraping.
--maximum -m Maximum number of items to scrape.
--media-metadata Saves the media metadata associated with the user's posts to
<destination>/<username>.json. Can be combined with --media-types none
to only fetch the metadata without downloading the media.
--include-location Includes location metadata when saving media metadata.
Implicitly includes --media-metadata.
--profile-metadata Saves the user profile metadata to <destination>/<username>.json.
--proxies Enable use of proxies, add a valid JSON with http or/and https urls.
Example: '{"http": "http://<ip>:<port>", "http": "https://<ip>:<port>" }'
--comments Saves the comment metadata associated with the posts to
<destination>/<username>.json. Implicitly includes --media-metadata.
--interactive -i Enables interactive login challenge solving. Has 2 modes: SMS and Email
--retry-forever Retry download attempts endlessly when errors are received
--tag Scrapes the specified hashtag for media.
--filter Scrapes the specified hashtag within a user's media.
--location Scrapes the specified instagram location-id for media.
--search-location Search for a location by name. Useful for determining the location-id of
a specific place.
--template -T Customize and format each file's name.
Default: {urlname}
Options:
{username}: Scraped user
{shortcode}: Post shortcode (profile_pic and story are empty)
{urlname}: Original file name from url.
{mediatype}: The type of media being downloaded.
{datetime}: Date and time of upload. (Format: 20180101 01h01m01s)
{date}: Date of upload. (Format: 20180101)
{year}: Year of upload. (Format: 2018)
{month}: Month of upload. (Format: 01-12)
{day}: Day of upload. (Format: 01-31)
{h}: Hour of upload. (Format: 00-23h)
{m}: Minute of upload. (Format: 00-59m)
{s}: Second of upload. (Format: 00-59s)
If the template is invalid, it will revert to the default.
Does not work with --tag and --location.
注意事项:
- 如果没有设置VPN则不能下载
- 部分私人账号,如果没有登录并关注则也不能下载图片
- github 项目地址传送门:https://github.com/rarcega/instagram-scraper
求点赞,求收藏,如果有其他疑问,欢迎私信或评论留言进行讨论,我会第一时间进行答疑~