Php retrieves images and DIV content instances from webpages. A simple method for php to retrieve images and DIV content on a webpage is implemented through regular expressions. 1. get all the images on the webpage :? Php obtains the content of a specified address, and saves and shares the simple method of php getting images and DIV content on a webpage, which is implemented through regular expressions.
1. retrieve all images on the webpage:
/I ', $ text, $ match); // Print the match print_r ($ match);?>
2. obtain the first image on the webpage:
/Ui ', $ text, $ match); // Print out matchprint_r ($ match);?>
3. obtain the specific p block data on the specified webpage:
] * Id = "PostContent" [^>] *> (.*?)
/Si', $ text, $ match); // print the match [0] print ($ match [0]);?>
4. The combination of the above 2 and 3:
] * Id = "PostContent" [^>] *> (.*?)
/Si', $ text, $ match); // obtain the first img tag and store it in a two-dimensional array $ match2 preg_match ('/] *>/Ui ', $ text, $ match2); // Print out match2 [0] print_r ($ match2 [0]);?>
Bytes. 1. get all the images on the webpage :? Php // Obtain the content of the specified address and store it...