I have a page where you can put in a web address in a form that will display all the li tags and contents on the same page. I have looked all over the internet and other forms about this area and only seen the content returned. I need the form to show something like this:
Thanks,
r
Here is the code I have.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>Find all li tags</h1>
<?php
if (isset($_POST['seturl']) && !empty($_POST['seturl'])) {
// process page for li tags
$url = sprintf('http://www.%s', $_POST["seturl"]);
echo "<p>Webpage being processed - ".$url."</p>";
//open the web page as a file
$fp = @fopen($url,'r') or
die('<h2 align="center">Cannot access web page</h2>');
//read the data
while(!feof($fp)) {
$line = fgets($fp);
$pattern = '/<li>(+?)<\/li>/i';
preg_match_all($pattern, $line, $found);
if ($found >= 1 ) {
$startpos = strpos($line,"<li");
$endpos = strpos($line,"li>");
while ($found > 0) {
$litag = substr($line, $startpos, ($endpos - $startpos + 2));
echo "<p>".$litag."</p>";
$found--;
$startpos = strpos($line,"<li",$startpos + 1);
$endpos = strpos($line,"li>",$startpos + 1);
}
}
}
// Close the "file"
fclose ($fp);
}
else {
?>
<form action="find_li.php" method="post">
<table border="0" cellspacing="2" cellpadding="2" >
<tr><td>Enter URL below.</td></tr>
<tr><td>www.<input type="text" name="seturl" size="40" /></td></tr>
<tr><td><input type="submit" value="Get Web Page" /></td></tr>
</table>
</form>
<?php } ?>
</body>
</html>