For example
There is no problem accessing the first image from this webpage
https://ask.csdn.net/questions/676365
Access the image link directly in the browser address bar and cannot access it
https://img-ask.csdn.net/upload/201712/29/1514512374_397838.jpg
How do you do this? I also want to make a similar function
The other party's server is configured with anti-leeching. Generally, the source is verified, which is the referer field in the http header. When you access the page, the browser has its own Referer field. You enter the URL directly from the address bar and the referer is empty. , so it cannot be accessed. You can use the CURL command line tool to test the specific reason
URL is sound Principle: When opening a picture, a token is generated and the TOKEN is sent to the corresponding picture server. If the TOKEN is incorrect, the picture cannot be opened
Maybe it’s anti-hotlink protection