About the third-party image resource 403 problem

In response to business needs:
Insert picture description here
Problem: Many image resource requests in the article list data failed, and 403 was returned

Reason:
This is because the interface data of our project is the content of the third-party platform crawled by the backend through crawlers, and the third-party platform has done anti-leech protection processing for the image resources.

How the third-party platform handles image resource protection: The
server generally uses the Referer request header to identify the source of the visit, and then handles what the resource visit
Insert picture description hereReferer is. For details, see Teacher Ruan Yifeng’s blog

Referer: Referrer, referrer. Who introduced you? For companies, this is very useful information.
The same is true on the Internet. You don’t visit a webpage for no reason. Someone always tells you that you can go there and check it out. The server also wants to know, who is your "referrer"?

The HTTP protocol has designed a Referer field in the request header to give the URL of the "referring web page".

Referer is a part of the HTTP request header. When the browser sends a request to the Web server, it will usually bring the Referer, which contains the address of the source page of the currently requested resource. The server generally uses the Referer request header to identify the source of access, which may be used for statistical analysis, log recording, and cache optimization.

How to solve this kind of problem:

Don’t send a referrer, the other server won’t know where you came from, so let’s assume that you are yours.

How to set not to send referrer?

1、用 <a>、<area>、<img>、<iframe>、<script> 或者 <link> 元素上的
 referrerpolicy 属性为其设置独立的请求策略,例如:
<img src="http://……" referrerPolicy="no-referrer">
2、或者直接在 HTMl 页面头中通过 meta 属性全局配置:
<meta name="referrer" content="no-referrer" />

Guess you like

Origin blog.csdn.net/weixin_43131046/article/details/115198704