PHP crawls web page code. I am using php code to capture the URL code first. , Ob_start (); & nbsp; $ chcurl_init (); & nbsp; curl_setopt ($ ch, CURLOPT_URL, $ url); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ($ PHP crawls webpage code and image path problems
I will first use php code to capture the code for connecting to the URL. ,
Ob_start ();
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
$ Retrievedhtml = curl_exec ($ ch );
Ob_end_clean ();
Curl_close ($ ch );
Now there is a situation, for example, the Web site is http://www.aaa.com/bq/
Then the link address of the image on the webpage is
At this time, it is reasonable to say that the complete URL of the image should be http://www.aaa.com/bq/cq/a.jpg
However, after the conversion, I found that the image cannot be displayed, and then I found that the image path is actually
Http://www.aaa.com/cq/a.jpg
How can I explain this and determine the path?
------ Solution --------------------
Generally, it's not/bq/cq/a.jpg.
Take a good look at this path:
/To the root
Picture path is http://www.aaa.com/cq/a.jpg
You can test a few more images and immediately understand that there is no dot in front of/. jump to the root node. if there is a dot, you can skip to the current path.
------ Solution --------------------
The domain name is relative to the domain name.
The url is relative to the url.
Don't you write your own website?
Just capture others?