Browse Source

test

feature/for_windows_video_compress_sxs20200923
nicksxs 6 years ago
parent
commit
8381c3d8c7
2 changed files with 66 additions and 5 deletions
  1. +3
    -1
      app/Console/Commands/InstagramScrape.php
  2. +63
    -4
      app/Services/InstagramService.php

+ 3
- 1
app/Console/Commands/InstagramScrape.php View File

@ -41,6 +41,8 @@ class InstagramScrape extends Command
// //
$ins = new InstagramService(); $ins = new InstagramService();
// $ins->scrapeUsers(); // $ins->scrapeUsers();
$ins->queryFollowUsers();
$ins->getUserNameById();
// $ins->queryFollowUsers();
// $ins->commonRequest();
} }
} }

+ 63
- 4
app/Services/InstagramService.php View File

@ -5,7 +5,9 @@ namespace App\Services;
set_time_limit(0); set_time_limit(0);
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
use GuzzleHttp\Client;
use GuzzleHttp\Command\Guzzle\GuzzleClient; use GuzzleHttp\Command\Guzzle\GuzzleClient;
use GuzzleHttp\Cookie\SetCookie;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use InstagramAPI\Response\Model\Item; use InstagramAPI\Response\Model\Item;
@ -475,7 +477,22 @@ class InstagramService
echo 'Something went wrong: ' . $e->getMessage() . "\n"; echo 'Something went wrong: ' . $e->getMessage() . "\n";
exit(0); exit(0);
} }
dump($ig->people->getInfoById($id));
$response = $ig->timeline->getUserFeed('12801506409', null);
// $response = $ig->story->getUserReelMediaFeed('12801506409');
dump($response);exit;
$rankToken = \InstagramAPI\Signatures::generateUUID();
$res = $ig->people->getSelfFollowing($rankToken);
Log::info($res->asJson());
dump($res);exit;
$users = $res->getUsers();
foreach ($users as $user) {
Log::info(json_encode($user->getUserId()));
if ($user->getPk() == '12801506409' || $user->getUserId() == '12801506409') {
dump($user);
}
}
} }
public function queryFollowUsers() public function queryFollowUsers()
@ -523,9 +540,51 @@ class InstagramService
} }
private function commonRequest($url, $params)
public function commonRequest($url = "https://www.instagram.com/graphql/query/", $params = [])
{ {
$request = new GuzzleClient();
$request->
$header = [
"authority" => "www.instagram.com",
"pragma" => "no-cache",
"cache-control " => "no-cache",
"accept" => " */*",
"x-ig-www-claim" => " hmac.AR2DN3JP5T1uzerp-Udyl58luFekDMO1MUYZolRys4KAvNm6",
"x-requested-with" => " XMLHttpRequest",
"user-agent" => " Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
"x-csrftoken" => " 7WVPjhWHhNqm2h1wcnslDgdkJJ9Ahqc6",
"x-ig-app-id" => " 936619743392459",
"sec-fetch-site" => " same-origin",
"sec-fetch-mode" => " cors",
"referer" => " https://www.instagram.com/nicksxs/following/",
"accept-encoding" => " gzip, deflate, br",
"accept-language" => " zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-TW;q=0.6,ja;q=0.5",
// "cookie" => " mid=XPJbKwAEAAEjcIilinpyKblsZqyx; fbm_124024574287414=base_domain=.instagram.com; ig_cb=1; ig_did=398CBD62-5C55-40BF-B917-0972BEE47035; csrftoken=7WVPjhWHhNqm2h1wcnslDgdkJJ9Ahqc6; ds_user_id=361404591; sessionid=361404591%3AJSLulZCziyeBSQ%3A5; shbid=13796; shbts=1581407718.4487948; rur=PRN; urlgen=\"{\"2607:fcd0:100:4600::5:d6c0\": 8100}:1j1Qy8:f8y9XAMkFUmNt5rl-hcF2hx9-74\""
];
$jar = new \GuzzleHttp\Cookie\CookieJar;
$jar->setCookie(SetCookie::fromString("mid=XPJbKwAEAAEjcIilinpyKblsZqyx; fbm_124024574287414=base_domain=.instagram.com; ig_cb=1; ig_did=398CBD62-5C55-40BF-B917-0972BEE47035; csrftoken=7WVPjhWHhNqm2h1wcnslDgdkJJ9Ahqc6; ds_user_id=361404591; sessionid=361404591%3AJSLulZCziyeBSQ%3A5; shbid=13796; shbts=1581407718.4487948; rur=PRN; urlgen=\"{\"2607:fcd0:100:4600::5:d6c0\": 8100}:1j1Qy8:f8y9XAMkFUmNt5rl-hcF2hx9-74\""));
$params = [];
$params["id"] = 361404591;
$params["include_reel"] = true;
$params["first"] = 24;
$var = json_encode($params);
$query = [
"variables" => $var,
"query_hash" => "d04b0a864b4b54837c0d870b0e77e076"
];
$request = new Client();
$res = $request->request("GET", $url,
[
"headers" => $header,
"query" => $query,
"cookie" => $jar,
'proxy' => [
'http' => 'http://127.0.0.1:1087', // Use this proxy with "http"
'https' => 'http://127.0.0.1:1087', // Use this proxy with "https",
],
'allow_redirects' => true,
'timeout' => 2000,
'http_errors' => true,
'verify' => false
]);
dump($res->getBody());
} }
} }

Loading…
Cancel
Save