google怎么批量展开点_Python 项目分享-Instagram批量下载

aa908f06c125e1a37265ea0e304afacf.png

相信很多人都会刷Instagram,当你看到漂亮的小姐姐,喜欢的Po主,总会忍不住想要把图片下载下来,我之前用的是手机上的APP插件,只要复制网页链接到下载APP内,就会自动将这条帖子的所有图片视频保存下来,但是始终不够方便。

如果你想批量下载指定用户的图片时,可能就比较麻烦。我一开始以为谷歌插件会支持这个功能,于是使用了如下谷歌商店的插件。

https://chrome.google.com/webstore/detail/downloader-for-instagram/olkpikmlhoaojbbmmpejnimiglejmboe​chrome.google.com

他比手机上使用更加方便,当在PC端刷Instagram时,只要点击图片左上角download即可使用。

542b52d9c9ee119881a2c7ce338bf091.png

72c4dd44828f591b338a898845529beb.png
当进入用户个人界面时,右上角也有批量下载按钮

涉及到单张图片下载时,还比较方便,但批量下载功能只支持用户主页的第一张图片,

ba82b0145d89a79e3c20c6733b3a1dc9.png
仅支持封面下载

于是我就尝试搜索instagram批量下载功能,在github发现了如下项目:

https://github.com/rarcega/instagram-scraper​github.com

instagram-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
爬取过程图示

当全部图片下载完以后,就可以在自己的个人用户目录下,找到爬取用户的文件夹,里面所有的照片和视频就都保存下来了。通过这个方法,可以爬取很多自己喜欢的明星、博主、小姐姐照片。

其他:

--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.

注意事项:

  1. 如果没有设置VPN则不能下载
  2. 部分私人账号,如果没有登录并关注则也不能下载图片
  3. github 项目地址传送门:https://github.com/rarcega/instagram-scraper

求点赞,求收藏,如果有其他疑问,欢迎私信或评论留言进行讨论,我会第一时间进行答疑~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
创建关注者/关注IG帐户的列表,找到2个IG帐户的普通用户,大量关注,喜欢您的Feed中的帖子 版本0.315 - 允许喜欢在您的饲料中的帖子,这是非常有用的,当你跟随很多的用户,并希望让所有人都高兴。 版本0.314 - 允许从生成的用户列表中发送所有未被遵守/未被请求的用户的追踪请求。 版本0.308 - 允许将获取的用户数量限制为第一个返回的用户数量。从我的观察来看,最初的追随者/追随者是在一开始就返回的,因此限制产出对于获得最新的关系是有用的,特别是对于关系数量巨大的账户。如果在输入框中限制值为0,并且是打开扩展弹出窗口时的默认值,则不应用限制。 版本0.305 - 稳定的版本,所有发现的缺陷是固定的,也改变了流程,使结果更快 - 最初显示短信息列表,并获取详细信息在后台运行。当获取详细信息完成后,显示详细信息列表。 版本0.301 - 版本调整为Instagram.com新的API,可能包含错误,并有改进的空间,继续工作。但至少核心功能再次起作用。 版本0.290 - 导入到Excel,更加改进了HTTP 429错误的处理,错误修正和改进,包括指示当承诺的追随者/追随者数量与实际返回的用户数量不一致的情况(可能会发生多个帐户连接的用户)。 版本0.280 - 错误修正,流程优化,性能改进,HTTP 429错误的改进错误处理,添加别名<< YOU>>。 版本0.260 - 增加了在两个instagram帐户之间寻找普通用户的功能。 这是为什么? 你有没有试图找到你关注的Instagram用户,谁不关注你?你有没有想过创建一个你的名单,或者不只是你的追随者和跟随用户?你有没有想过出口这样的名单?我做了,但是我没有找到简单和安全的方式来做到这一。因此我决定自己实现这样的功能并共享它。因此,使用此扩展程序,您可以将您的追随者和您关注的用户合并到一个列表中,并选择将其导出为CSV文件。实际上,您不仅可以导出您的关注者和关注用户,还可以导出您允许关注的任何公共账户或私人账户。 怎么样? 当您单击扩展图标时,弹出窗口将显示包含用户名的输入框(扩展名试图从URL中提取用户名或者您可以自己输入名称),导出范围(全部,用户关注或用户后面跟着)和“Get Insta Users”按钮。击这个按钮,你将被带到结果页面,并启动用户的导出过程。这个版本的性能得到了改进,例如8438个用户在838秒内出口。 当程序完成后,页面会显示用户的图片,身份证号码,姓名,身份,跟踪用户的指示,用户是否跟随你的指示,用户账户是否私密,跟随者的数量,跟随账户的数量和员额。显示的页面具有搜索和排序功能。 技术细节。 这个扩展的源代码可以在GitHub上找到,所以你可以验证它不做任何不允许的事情。它将AJAX请求发送到Instagram服务器以检索用户列表及其详细信息。这些请求是代表你发送的。有两个选项: 1)一次通话中返回的用户数量。默认值是100,但是调试这个功能后,我意识到Instagram的服务器并不太重视这个参数,通常在一次调用中返回约20个用户。 2)发出下一个请求之前的延迟,默认值为1000毫秒。如果没有延迟,为了获取长长的用户列表,Instagram可以返回HTTP代码429(请求太多,几分钟后尝试)。目前这种情况还没有得到处理,唯一的办法是拖延。 访问http://instascraper.weebly.com获取更多信息。 支持语言:English (United States)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值