alohatofu Posted April 20, 2007 Share Posted April 20, 2007 I have a sample page located at http://projectkamalii.org/sampledata.htm could someone please guide me on how to extract that data out? I'm thinking of using snoopy to assign each field a variable but don't know where to start. could someone give me some guidance please? I'm thinking of fetching the page with php and then output each field a variable say the first field is Notice_ID would output 0068996 Link to comment https://forums.phpfreaks.com/topic/47962-parsing-html-document/ Share on other sites More sharing options...
dustinnoe Posted April 21, 2007 Share Posted April 21, 2007 I think I would start with <a href="http://us2.php.net/preg_match">preg_match()</a> using the "matches" parameter Link to comment https://forums.phpfreaks.com/topic/47962-parsing-html-document/#findComment-234378 Share on other sites More sharing options...
alohatofu Posted April 21, 2007 Author Share Posted April 21, 2007 how would you do it? the data is in a table. thanks Link to comment https://forums.phpfreaks.com/topic/47962-parsing-html-document/#findComment-234382 Share on other sites More sharing options...
dustinnoe Posted April 21, 2007 Share Posted April 21, 2007 http://www.phpfreaks.com/forums/index.php/topic,127902.0.html Here are the resources you will need. It's worth learning this on your own as opposed to someone writing the code for you. I struggled through it and I'm glad I did. Link to comment https://forums.phpfreaks.com/topic/47962-parsing-html-document/#findComment-234388 Share on other sites More sharing options...
alohatofu Posted April 21, 2007 Author Share Posted April 21, 2007 thanks!. my concern is how do I initiate it. I will learn preg_match but please guide me on how to start with that html file. Link to comment https://forums.phpfreaks.com/topic/47962-parsing-html-document/#findComment-234406 Share on other sites More sharing options...
corbin Posted April 21, 2007 Share Posted April 21, 2007 $htmlfile = implode("\r\n", file(path or url to html file....)); That would put the file contents in $htmlfile Link to comment https://forums.phpfreaks.com/topic/47962-parsing-html-document/#findComment-234499 Share on other sites More sharing options...
alohatofu Posted April 21, 2007 Author Share Posted April 21, 2007 Ok, I've got it to where it will display all the text only. <?php include("include/classes/Snoopy.class.php"); $snoopy = new Snoopy; if($snoopy->fetchtext("http://xxx.xxx.xxxx.xxx/events/noticedetails.php?noticeID=0069040")){ // print the texts of the website: print "<pre>".htmlspecialchars($snoopy->results)."</pre>\n"; } else { print "Snoopy: error while fetching document: ".$snoopy->error."\n"; } ?> the output of that code is something like this this is the first line this is the 2nd line of the paragraph a thirdline is here My question is can someone please guide me on how to not display the text but assign variables to to the text above? say I want $var1 = first line thanks Link to comment https://forums.phpfreaks.com/topic/47962-parsing-html-document/#findComment-234552 Share on other sites More sharing options...
alohatofu Posted April 21, 2007 Author Share Posted April 21, 2007 Ok, let's just say that I don't dispaly the result but store them $result = ($snoopy->results); what's the next step? let's say that I want to get the word "first" in $result Link to comment https://forums.phpfreaks.com/topic/47962-parsing-html-document/#findComment-234555 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.