Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem that the pictures of articles collected by php will not be displayed?

Shulou Source: shulou.com Published: 2022-06-03 04:11:09 11月13日 Update

This article introduces the relevant knowledge of "how to solve the problem that the pictures of articles collected by php do not display". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The solution to not displaying the pictures of articles collected by php: 1. Collect Baidu search results according to keywords; 2. Make a batch conversion of the collected html according to the defined domain name.

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

What should I do if the picture of the article collected by php is not displayed?

The solution to the problem of not displaying pictures of Baidu search results collected by PHP CURL

1. Collect Baidu search results according to keywords

You can use curl to collect Baidu search results based on keywords. The code is as follows:

After output, it is found that some pictures cannot be displayed.

two。 Analysis of the reasons why the collected pictures are not displayed

Search directly in Baidu, the page can display pictures. Using firebug to view the image path, it is found that the collected image domain name is different from the image domain name searched in Baidu.

Collect the returned image domain name t11.baidu.com

Normal search image domain name ss1.baidu.com

Check the html of collection and normal search, and find that the js with domain name conversion is different.

Acquisition

Var list = {

"graph.baidu.com": "http://graph.baidu.com","

"t1.baidu.com": "http://t1.baidu.com","

"t2.baidu.com": "http://t2.baidu.com","

"t3.baidu.com": "http://t3.baidu.com","

"t10.baidu.com": "http://t10.baidu.com","

"t11.baidu.com": "http://t11.baidu.com","

"t12.baidu.com": "http://t12.baidu.com","

"i7.baidu.com": "http://i7.baidu.com","

"i8.baidu.com": "http://i8.baidu.com","

"i9.baidu.com": "http://i9.baidu.com","

}

Normal search

Var list = {

"graph.baidu.com": "https://sp0.baidu.com/-aYHfD0a2gU2pMbgoY3K","

"t1.baidu.com": "https://ss0.baidu.com/6ON1bjeh2BF3odCf","

"t2.baidu.com": "https://ss1.baidu.com/6OZ1bjeh2BF3odCf","

"t3.baidu.com": "https://ss2.baidu.com/6OV1bjeh2BF3odCf","

"t10.baidu.com": "https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq","

"t11.baidu.com": "https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq","

"t12.baidu.com": "https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq","

"i7.baidu.com": "https://ss0.baidu.com/73F1bjeh2BF3odCf","

"i8.baidu.com": "https://ss0.baidu.com/73x1bjeh2BF3odCf","

"i9.baidu.com": "https://ss0.baidu.com/73t1bjeh2BF3odCf","

}

Therefore, it can be concluded that Baidu will return different js if it is collected according to the source address, IP, header and other parameters.

3. The solution of not displaying the picture after collection

Make a batch conversion of the collected html according to the defined domain name.

After adding the domain name conversion, all the pictures can be displayed normally.

This is the end of the content of "how to solve the problem that the pictures of articles collected by php do not display". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Picture domain name article result key keyword different fairy sword content knight-errant method more knowledge output practical successful learning next search code method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology OPPO Reno Apple NVidia Docker