I don’t know if you’ve encountered this, but when we use things like Fiddler and Charles to capture packets, it works fine, but when we copy the requested Url to the browser to make the request, we get 403 errors. The 403 error is a common deny access error in our network requests. As shown below, we are fine in Charles, but we get 403 error when accessing in a browser or using Postman.

For 403 to prevent access, we usually just need to add the corresponding header argument. You can copy the complete request for what parameters are required and then analyze the header information. The following parameters are usually required:

The req. Add_header (" the user-agent ", "Mozilla / 5.0 (Windows NT 6.3; WOW64) AppleWebKit / 537.36 (KHTML, Add_header ("GET", URL) req.add_header("Host","blog.xxx.net") req.add_header("Referer","http://www.xxx.net/")Copy the code

For example, in the previous example, AFTER I added all the header arguments I needed, I was ready to request.