dilbertone Posted May 24, 2011 Share Posted May 24, 2011 hello dear community, good day i have a problem - a parser that does not parse. IT does not work! It gives not back anything! <?PHP // Original PHP code by Chirp Internet: http://www.chirp.com.au // Please acknowledge use of this code by including this header. $url = "http://www.edi.admin.ch/esv/00475/00698/index.html?lang=de"; //$input = @file_get_contents($url) or die("Could not access file: $url"); $input = file_get_contents($url) or die("Could not access file: $url"); $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; if(preg_match_all("/$regexp/siU", $input, $matches, PREG_SET_ORDER)) { foreach($matches as $match) { // $match[2] = all the data i want to collect... // $match[3] = text that i need to collect - see a detail-page } } ?> well - it goes a bit over my head: "what - i have did" - it does not give back any results!? i look forward to hear from you! regards Quote Link to comment Share on other sites More sharing options...
gizmola Posted May 24, 2011 Share Posted May 24, 2011 That code snippet does not output anything via var_dump() or echo. Quote Link to comment Share on other sites More sharing options...
xyph Posted May 24, 2011 Share Posted May 24, 2011 There's no echo or print call. Try print_r($matches) to see what's going on Quote Link to comment Share on other sites More sharing options...
dilbertone Posted May 24, 2011 Author Share Posted May 24, 2011 hi gizmola hello xyph thanks for answering! i am happy! That code snippet does not output anything via var_dump() or echo. many many thanks.- That means i have to rewrite this part!? - gizmola - i am a newbie; I will try it. But perhaps you can help me!? Update; i will definitly try this one: print_r($matches) to see what's going on lookforward - best regards martin Quote Link to comment Share on other sites More sharing options...
gizmola Posted May 24, 2011 Share Posted May 24, 2011 Did you try what xyph suggested. Being a noobie does not excuse one from actually doing some reading and learning. There is nothing more basic than output... print_r, echo, var_dump, die. You need to read about these in the php manual, not to mention the functions in the code you are using. Quote Link to comment Share on other sites More sharing options...
dilbertone Posted May 24, 2011 Author Share Posted May 24, 2011 hello dear friends this code first of all: a big big SORRY for being the Newbie - @gizmola: i did the changes: Did you try what xyph suggested. Being a noobie does not excuse one from actually doing some reading and learning. There is nothing more basic than output... print_r(), echo(), var_dump(), die(). You need to read about these in the php manual, not to mention the functions in the code you are using. well i guess that i did the changes... but i had no luck... look and see - this is so mystic! i do not know whats going one here: <?PHP // Original PHP code by Chirp Internet: http://www.chirp.com.au // Please acknowledge use of this code by including this header. $url = "http://www.edi.admin.ch/esv/00475/00698/index.html?lang=de"; //$input = @file_get_contents($url) or die("Could not access file: $url"); $input = file_get_contents($url) or die("Could not access file: $url"); $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; if(preg_match_all("/$regexp/siU", $input, $matches, PREG_SET_ORDER)) { foreach($matches as $match) { // $match[2] = all the data i want to collect... // $match[3] = text that i need to collect - see a detail-page print_r($matches) } } ?> gives back martin@suse-linux:~/perl/foundations> php fondations_de.php PHP Parse error: syntax error, unexpected '}' in /home/martin/perl/foundations/fondations_de.php on line 20 martin@suse-linux:~/perl/foundations> ^C martin@suse-linux:~/perl/foundations> Quote Link to comment Share on other sites More sharing options...
gizmola Posted May 24, 2011 Share Posted May 24, 2011 Statements require a semi-colon at the end. print_r($matches) ; Quote Link to comment Share on other sites More sharing options...
dilbertone Posted May 24, 2011 Author Share Posted May 24, 2011 hello gitzmola - many many thanks i will have a look! on a sidenote: - and i also want to look if the parser-part runs ... Guess the part that FETCHES the data is not so complicated as the part that parses the data... anyway - many many thanks for any and alll help! i come back and report all my findings!! greetings db1 UPDATE: - HELLO DEAR FRIENDS: -this gives back something very very intersting. ... well see: (i have postet only a part.... the whole stuff is tooo big to post here.... ) But wait: what can i do!? note - i want to get all the data out of this database: http://www.edi.admin.ch/esv/00475/00698/index.html?lang=de At the moment we have these results: how to proceed: ?! [16] => Array ( [0] => <a href="/esv/index/index.html?lang=de" title="Zum Schlagwort-Index" class="webServiceContent" accesskey="6">Index</a> [1] => " [2] => /esv/index/index.html?lang=de [3] => Index ) [17] => Array ( [0] => <a href="/esv/printtool/index.html?lang=de" title="Printtool" class="webServiceContent">Printtool</a> [1] => " [2] => /esv/printtool/index.html?lang=de [3] => Printtool ) [18] => Array ( [0] => <a href="/hinweise/index.html?lang=de" title="Zu den Bedienungshinweisen" class="webServiceContent">Hilfe</a> [1] => " [2] => /hinweise/index.html?lang=de [3] => Hilfe ) [19] => Array ( [0] => <a href="/esv/00475/00698/index.html?lang=de" class="webSpracheAktiv" title="Diese Seite auf deutsch">Deutsch</a> [1] => " [2] => /esv/00475/00698/index.html?lang=de [3] => Deutsch ) [20] => Array ( [0] => <a href="/esv/00475/00698/index.html?lang=fr" class="webSpracheInaktiv" title="Cette page en fran�ais">Fran�ais</a> [1] => " [2] => /esv/00475/00698/index.html?lang=fr [3] => Fran�ais ) .....and so forth and so forth!! ... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.