Re: Parsing html to extract images
| From: | David Grant | Date: | Thu, 29 May 2003 08:03:02 +0000 |
| Subject: | Re: Parsing html to extract images | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-149351@lists.php.net to get a copy of this message | ||
Hidrahyl wrote:
Hi, anyone can help me parsing html files in order to get all the images containing a file? Thanks, Simon.1. Use fopen() to grab the HTML file you're after. 2. Read in each line to an array using file(); 3. Loop through the array, and apply the following reg. exp.: preg_match("/\<img.*src=[\"\'](.*)[\"\'].*\>/U", $line, $matches); NOTE: this might need a bit of tweeking, since I'm not too hot on regular expressions... :) Regards, David -- David Grant Web Developer david.grant@wiredmedia.co.uk http://www.wiredmedia.co.uk Tel: 0117 930 4365, Fax: 0870 169 7625 Wired Media Ltd Registered Office: 43 Royal Park, Bristol, BS8 3AN Studio: Whittakers House, 32 - 34 Hotwell Road, Bristol, BS8 4UD Company registration number: 4016744 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. **********************************************************************