Page 1 of 1

Extracting specific Html codes from websites

Posted: Wed Aug 20, 2008 11:16 pm
by thankyou
Hi everyone,

I need help in extracting html codes from websites.
There are some program that can extract captchas from websites. Some directories submitter software has it.

Let me give an example for a better picture.
let's say I want to extract form codes from a page.
So I want this program/script to extract the whole codes from
<form.... until ...</form>

How do I do that in php?

Re: Extracting specific Html codes from websites

Posted: Thu Aug 21, 2008 12:43 am
by it2051229
do you know XML? php has this xml feature... you can parse XML... basically html tags are like xml anyway.. but xml will surely solve your problem.

Re: Extracting specific Html codes from websites

Posted: Thu Aug 21, 2008 12:45 am
by s.dot
Look at preg_match() or preg_match_all()

Code: Select all

preg_match_all('/<form>.+?<\/form>/ism', $HTMLContents, $matches);
 
echo '<pre>';
print_r($matches);
echo '</pre>';