I ran into a problem, namely, bypassing the restriction of the request in this link https://www.instagram.com/'+ Parse + '/? __ A = 1'
. I tried to bypass through User-Agent substitution, but I did not work anything
import json
Import urllib.request
Headers = {
'User-Agent': 'Mozilla / 5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit / 537.36 (KHTML, LIKE GECKO) Chrome / 35.0.1916.47 Safari / 537.36'
}
url = 'https://www.instagram.com/zuck/?__a=1'
RQ = URLLIB.Request.Request (URL, Headers = Headers)
Data1 = UrLLIB.Request.urlopen (RQ)
Data = JSON.Loads (Data1.Read ())
Print ("ID", Data ['Graphql'] ['User'] ['id'])
Answer 1, Authority 100%
http 429 too Many Requests The answer code indicates that the user sent too many requests for the last time (“speed limit” or “Rate Limiting”).
You can get around:
- make pauses between requests;
- change user-agent;
- change IP via proxies
But 429 can be found with a single request:
& gt; & gt; & gt; Import Requests.
& gt; & gt; & gt; url = 'https://www.instagram.com/geeks_for_geeks/'
& gt; & gt; & gt; Headers = {'User-Agent': 'Mozilla / 5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit / 537.36 (KHTML, LIKE GECKO) Chrome / 35.0.1916.47 Safari / 537.36'}
& gt; & gt; & gt; R = Requests.get (URL, Headers)
& gt; & gt; & gt; R.
& lt; response [429] & gt;
And when specifying Headers = Headers
:
& gt; & gt; & gt; R = Requests.get (URL, Headers = Headers)
& gt; & gt; & gt; R.
& lt; response [200] & gt;