now you visit https://www.instagram.com and view the source code of this html page, you can't
find "rhx_gis" . Therefore methods relevant to "rhx_gis" will not work (getMedias, getMediasByUserId. etc).
It seems that instagram updates their policy to prevent from scraping.
Any new way to solve this problem锛燂紵
@raiym
oh it seems that you just need to remove 'rhx_gis', and you will get the response.
it means you don't need to call generateGisToken() when you generate request headers
in method getMediasByUserId like:
// $response = Request::get(Endpoints::getAccountMediasJsonLink($variables), $this->generateHeaders($this->userSession, $this->generateGisToken($variables)));
$response = Request::get(Endpoints::getAccountMediasJsonLink($variables), $this->generateHeaders($this->userSession));
but I still don't know why instagram did so....
Hello!
From today I get an exception "Could not extract gis from page" when calling the method getMedias().
What offer to solve? @raiym
@newvv88
As what I mentioned above, Instagram will not render "rhx_gis" in the page from now on, and when you call method getMedias(), it will call method generateGisToken(), which causes the exception you had.
So what you need to do is that get into method getMedias(), and replace
$response = Request::get(Endpoints::getAccountMediasJsonLink($variables), $this->generateHeaders($this->userSession, $this->generateGisToken($variables)));
to
$response = Request::get(Endpoints::getAccountMediasJsonLink($variables), $this->generateHeaders($this->userSession));
Then you are supposed to fix the problem.
Hope it can help you
Yes thanks this works :]
Also combined with silencing any errors with '@' to stop the site breaking just in case Instagram changes again, as suggested here
$instagram = new \InstagramScraper\Instagram();
$nonPrivateAccountMedias = @$instagram->getMedias('example', 30);
_Originally posted by @MathiasGmeiner in https://github.com/postaddictme/instagram-php-scraper/issues/484#issuecomment-493123894_
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
@newvv88
As what I mentioned above, Instagram will not render "rhx_gis" in the page from now on, and when you call method getMedias(), it will call method generateGisToken(), which causes the exception you had.
So what you need to do is that get into method getMedias(), and replace
to
Then you are supposed to fix the problem.
Hope it can help you