Answer the question
In order to leave comments, you need to log in
Parse instagram accounts by location?
The question is about parsing profile descriptions, which I don't think should be a problem. However, the question is: is it possible to parse based on the user's location? For example a city. It seems that Instagram does not have such a function as filling in the country / city ...
Answer the question
In order to leave comments, you need to log in
I found such an example on php
php code works fine on phpfiddle.org
<?php
//переменные
$url_parser="https://www.instagram.com/explore/locations/123456/"; //ссылка для парсинга
$glubina_stranic="10"; //глубина парсинга, на одной странице 20 id пользователей
class instaWrapper {
static function getFeedByUrl($url) {
$source = file_get_contents($url);
if ($source == false) {
echo "Connection problem";
die();
}
$shards = explode('window._sharedData = ', $source);
$insta_json = explode(';</script>', $shards[1]);
$insta_array = json_decode($insta_json[0], TRUE);
if (isset($insta_array['entry_data']['ProfilePage']))
$nodes = $insta_array['entry_data']['ProfilePage'][0]['user']['media']['nodes'];
elseif (isset($insta_array['entry_data']['LocationsPage']))
$nodes = $insta_array['entry_data']['LocationsPage'][0]['location']['media']['nodes'];
elseif (isset($insta_array['entry_data']['TagPage']))
$nodes = $insta_array['entry_data']['TagPage'][0]['tag']['media']['nodes'];
$result=[];
foreach($nodes as $item) {
$result[]=[
"id" => $item['id'],
"code" => $item['code'],
"url" => "https://www.instagram.com/p/".$item['code'],
"timestamp" => $item['date'],
"date" => date("d.m.Y H:i:s", $item['date']),
"caption" => (isset($item['caption'])?$item['caption']:false),
"owner_id" => $item['owner']['id'],
"thumbnail_src" => $item['thumbnail_src'],
"image_src" => $item['display_src'],
"is_video" => (boolean)$item['is_video'],
"dimensions" => $item['dimensions']
];
}
return $result;
}
}
$insta_massiv = (
instaWrapper::getFeedByUrl("$url_parser")
);
for ($i = 1; $i < count($insta_massiv); $i++)
{
echo $insta_massiv[$i]['owner_id']."<br>";
$last_id_anketa = $insta_massiv[$i]['id'];
}
$x=0;
while ($x++<$glubina_stranic)
{
$insta_massiv = (
instaWrapper::getFeedByUrl("$url_parser?max_id=$last_id_anketa")
);
for ($i = 1; $i < count($insta_massiv); $i++)
{
echo $insta_massiv[$i]['owner_id']."<br>";
$last_id_anketa = $insta_massiv[$i]['id'];
}
}
?>
Not users are attached to the image, but Media. Geotags and that's it. But, keep in mind that the image can fast without them.
https://www.instagram.com/developer/endpoints/loca...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question