更新时间:2022-11-03 11:00:51
您可以获取所有图像.只需按page_info
对其进行迭代.此外,还有更方便的获取json的方法:
You can get all images. Just iterate them by page_info
. In addition, there is more convenient way to get json:
$otherPage = 'nasa';
$profileUrl = "https://www.instagram.com/$otherPage/?__a=1";
$iterationUrl = $profileUrl;
$tryNext = true;
$limit = 100;
$found = 0;
while ($tryNext) {
$tryNext = false;
$response = file_get_contents($iterationUrl);
if ($response === false) {
break;
}
$data = json_decode($response, true);
if ($data === null) {
break;
}
$media = $data['user']['media'];
$found += count($media['nodes']);
var_dump($media['nodes']);
if ($media['page_info']['has_next_page'] && $found < $limit) {
$iterationUrl = $profileUrl . '&max_id=' . $media['page_info']['end_cursor'];
$tryNext = true;
}
}