adinan-cenci / scraping-instagram
此包已废弃,不再维护。未建议替代包。
获取Instagram图片,无需API令牌。
1.0.4
2020-12-29 11:05 UTC
Requires
- php: >=5.3
README
Instagram为了保护其平台,到了让抓取它变得困难重重,从而违背了该库的简单使用目的。
很抱歉,但市面上有更适合这个用途的项目。
Instagram抓取
这是一个PHP库,用于抓取Instagram个人资料页面上的图片。无需API令牌。
为什么?
有些人喜欢在自己的网站上展示他们的Instagram图片,创建应用程序和生成令牌对于公开可用信息来说工作量太大,因此有了这个库。
是什么?
此库不会抓取某人的整个相册,只会抓取个人资料页面上显示的最近几张图片。如果您想一次性显示超过12张图片,您可能需要考虑缓存预览请求。
如何?
只需将用户的昵称传递给构造函数,并调用 ::fetch() 方法。
use AdinanCenci\ScrapingInstagram\Instagram; $scraper = new Instagram('noobmaster'); try { $pictures = $scraper->fetch(); } catch (\Exception $e) { echo 'Error: '.$e->getMessage(); die(); }
它将返回一个数组,描述图片如下
[ { "caption": "Lorem ipsum dolor sit amet, consectetur ....", "src": "https://instagram.ffln3....", "thumbnails": { "150x150": "https://instagram.ffln....", "240x240": "https://instagram.ffln....", "320x320": "https://instagram.ffln....", "480x480": "https://instagram.ffln....", "640x640": "https://instagram.ffln...." } }, { "caption": "Sed ut perspiciatis unde omnis iste ....", "src": "https://instagram.ffln3....", "thumbnails": { "150x150": "https://instagram.ffln....", "240x240": "https://instagram.ffln....", "320x320": "https://instagram.ffln....", "480x480": "https://instagram.ffln....", "640x640": "https://instagram.ffln...." } }, { "caption": "At vero eos et accusamus et iusto odio ....", "src": "https://instagram.ffln3....", "thumbnails": { "150x150": "https://instagram.ffln....", "240x240": "https://instagram.ffln....", "320x320": "https://instagram.ffln....", "480x480": "https://instagram.ffln....", "640x640": "https://instagram.ffln...." } } ]
::unique()
这是一个小方法,用于删除重复的图片,如果将要合并请求,将很有帮助。
$newPictures = $scrapper->fetch(); $pictures = array_merge($newPictures, $oldPictures); $pictures = Instagram::unique($pictures);
安装
使用composer
composer require adinan-cenci/scraping-instagram
许可证
MIT