Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $content = file_get_contents(__DIR__ . '/accounts');
- $accounts = explode("\n", $content);
- $accounts = array_filter(array_unique($accounts));
- if (empty($accounts)) {
- echo("Add accounts to file 'accounts', each in a new line.\n");
- }
- @mkdir(__DIR__ . '/res');
- @chmod(__DIR__ . '/res', 0777);
- foreach ($accounts as $account) {
- if (download($account)) {
- echo "$account - OK!\n";
- } else {
- echo "$account - ERR!\n";
- }
- //sleep(1); // in seconds
- }
- function download($username)
- {
- $url = "https://www.instagram.com/{$username}/";
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- //curl_setopt($ch, CURLOPT_HEADER, true);
- //curl_setopt($ch, CURLOPT_NOBODY, true);
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36');
- $content = curl_exec($ch);
- //print_r(curl_getinfo($ch));
- //print_r($content);
- if (curl_getinfo($ch, CURLINFO_HTTP_CODE) === 404) {
- return false;
- }
- preg_match('/\_sharedData \= (.*?)\;\<\/script\>/s', $content, $matches);
- $arr = json_decode($matches['1'], true, 512, JSON_BIGINT_AS_STRING);
- $url = $arr['entry_data']['ProfilePage']['0']['graphql']['user']['profile_pic_url_hd'];
- if (($image = file_get_contents($url))) {
- return file_put_contents(sprintf('%s%s%s_%s', __DIR__ . '/res', DIRECTORY_SEPARATOR, $username, basename($url)), $image);
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement