python3 利用Instaloader下载instagram数据示例

网友投稿 1150 2022-10-01

python3 利用Instaloader-instagram数据示例

python3 利用Instaloader-instagram数据示例

感想

最近发现了一个好用的python library:Instaloader,它能够做很多操作,我这里利用这个包从instagram上-图片+hashtag数据。

安装

pip3 install instaloader

-代码

download.py

with open('hashtags.txt', encoding="utf-8") as f: examples=f.readlines()hashtags=[]for item in examples: hashtag=item.strip().replace('#','') hashtags.append(hashtag)from datetime import datetimeimport instaloaderL = instaloader.Instaloader()for HASHTAG in hashtags: try: posts = L.get_hashtag_posts(HASHTAG) count=0 print(HASHTAG) for post in posts: if(post.is_video): continue if(count==10): break # print(post.date) L.download_post(post, target='#'+HASHTAG) count+=1 except Exception as e: print(e)

是不是很简单,几行代码就行了,简直吊炸天。

hastags.txt里面的为word,示例:

#love#instagood#photooftheday#fashion#beautiful#happy#cute#tbt#like4like#followme#picoftheday#follow#me#selfie#summer

当然还有很多其他的功能啦,详情请参考下面的文献

参考文献

[1].Instaloader.​​https://instaloader.github.io/index.html​​

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:微信小程序 暗黑模式(微信小程序怎么做店铺)
下一篇:在项目中直接使用hystrix的流程分析
相关文章

 发表评论

暂时没有评论,来抢沙发吧~