Browse Source

test

feature/for_windows_video_compress_sxs20200923
nicksxs 6 years ago
parent
commit
96f7d6a7d7
2 changed files with 39 additions and 24 deletions
  1. +2
    -2
      app/Console/Commands/InstagramScrape.php
  2. +37
    -22
      app/Services/InstagramService.php

+ 2
- 2
app/Console/Commands/InstagramScrape.php View File

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

+ 37
- 22
app/Services/InstagramService.php View File

@ -7,6 +7,7 @@ date_default_timezone_set('UTC');
use GuzzleHttp\Client;
use GuzzleHttp\Command\Guzzle\GuzzleClient;
use GuzzleHttp\Cookie\CookieJar;
use GuzzleHttp\Cookie\SetCookie;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Log;
@ -500,7 +501,8 @@ class InstagramService
$params = [];
$params["id"] = 361404591;
$params["include_reel"] = true;
$params["first"] = 24;
$params["first"] = 12;
$params["fetch_mutual"] = false;
$var = json_encode($params);
$curl = curl_init();
@ -545,46 +547,59 @@ class InstagramService
$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",
"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\""));
$cookieJar = CookieJar::fromArray([
'sessionid' => '361404591%3Ab13E3MH2Eis7QW%3A13',
'ds_user_id' => '361404591',
'ig_did' => '4B0E363A-C65C-4311-8117-CD49993B46F3',
'mid' => 'Xi2DdwAEAAFfFk6izuuXW0tMPSEx',
'rur' => 'PRN',
'shbid' => '13796',
'shbts' => '1581259038.7557411',
'urlgen' => '"{\"152.32.187.149\": 135377}:1j1sXK:mckgvU-Hvlbl4BuOgZrh21n1bjQ"'
], '.instagram.com');
$params = [];
$params["id"] = 361404591;
$params["include_reel"] = true;
$params["first"] = 24;
$params["first"] = 12;
$params["fetch_mutual"] = false;
$var = json_encode($params);
echo $var;
$query = [
"variables" => $var,
"query_hash" => "d04b0a864b4b54837c0d870b0e77e076"
];
$url = $url . "?query_hash=d04b0a864b4b54837c0d870b0e77e076&variables=$var";
dump($url);
$request = new Client();
$res = $request->request("GET", $url,
[
"headers" => $header,
"query" => $query,
"cookie" => $jar,
// "query" => $query,
"cookies" => $cookieJar,
'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
'http_errors' => true
]);
dump($res->getBody());
dump($res->getBody()->getContents());
}
}

Loading…
Cancel
Save