[SOLVED] Extract Web Data
Posted: Sun Jun 27, 2004 11:10 am
Hello,
I want to extract some data from an html site ......
and reformat some data between <pre> .. </pre> tags ..... pls help; as I am newbie ... this php code now not work ?
The html page is (encode with big5 char) ...
Requirement:
Output string to show the following :
Thanks very much ....
feyd | please use the
I want to extract some data from an html site ......
and reformat some data between <pre> .. </pre> tags ..... pls help; as I am newbie ... this php code now not work ?
Code: Select all
<?
$file = "http://something.htm";
$contents = file($file);
$size = sizeof($contents);
for($i = 0; $i < $size; $i++) {
$alldata = $contents[$i];
preg_match("/<pre.*?>(.+)<\/pre>/im",$alldata,$matches);
print_r($matches);
}
?>Code: Select all
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>something</title>
</head>
<body bgcolor="#FFFFFF">
<p align="center"><img src="../../images_e/logo_dblue.gif" alt="logo" width="333" height="65">
<h1 align="center">report</h1>
<p><i>report detail</i>
<pre>
line 1:
tag2 : data2
tag3 : data3
tag4 : number n - data4
line 5
line 6
line 7
</pre>
</body>
</html>Output string to show the following :
Code: Select all
line 1:
tag2 : data2
tag3 : data3
tag4 : data4feyd | please use the
Code: Select all
andCode: Select all
tags we've provided :: [/color][url=http://forums.devnetwork.net/viewtopic.php?t=21171][color=red]:arrow: [u][b]Posting Code in the Forums[/b][/u][/color][/url]