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 Link to comment https://forums.phpfreaks.com/topic/237370-help-me-in-combining-two-parts-of-my-20-liner-file_get_contents-parsing/ 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. Link to comment https://forums.phpfreaks.com/topic/237370-help-me-in-combining-two-parts-of-my-20-liner-file_get_contents-parsing/#findComment-1219742 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 Link to comment https://forums.phpfreaks.com/topic/237370-help-me-in-combining-two-parts-of-my-20-liner-file_get_contents-parsing/#findComment-1219744 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 Link to comment https://forums.phpfreaks.com/topic/237370-help-me-in-combining-two-parts-of-my-20-liner-file_get_contents-parsing/#findComment-1219750 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. Link to comment https://forums.phpfreaks.com/topic/237370-help-me-in-combining-two-parts-of-my-20-liner-file_get_contents-parsing/#findComment-1219752 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> Link to comment https://forums.phpfreaks.com/topic/237370-help-me-in-combining-two-parts-of-my-20-liner-file_get_contents-parsing/#findComment-1219758 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) ; Link to comment https://forums.phpfreaks.com/topic/237370-help-me-in-combining-two-parts-of-my-20-liner-file_get_contents-parsing/#findComment-1219760 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!! ... Link to comment https://forums.phpfreaks.com/topic/237370-help-me-in-combining-two-parts-of-my-20-liner-file_get_contents-parsing/#findComment-1219764 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.