mikelmao Posted October 6, 2011 Share Posted October 6, 2011 Hello everyone, Im trying to make a script which reads a certain page and retrieves certain information from that page. Im making an APP for my school and i want it to read the schedule on the website. What im doing right now is the APP recieves info from my web page using JSON, and my web page read's the schedule on my schools website. My problem is that it is not getting the correct output.. This is my script: <?php $navBar = file_get_contents('http://rst-vltn.roczeeland.nl/ovw/frames/navbar.htm'); preg_match('/<option value="(.*)">(.*)<\/option>/i', $navBar, $matches); $weekNumber = $matches[1]; $classNumber = 101; $type = 'c'; $roosterPage = 'http://rst-vltn.roczeeland.nl/ovw/'. $weekNumber .'/'. $type .'/'. $type .'00'. $classNumber .'.htm'; $rooster = file_get_contents($roosterPage); preg_match_all('/<font size="2" face="Arial">(.*)<\/font>/ix', $rooster, $matches2); echo var_dump($matches2); ?> So as you see in the preg_match_all function i want it to return the info between the <font> tags. The website im reading is: http://rst-vltn.roczeeland.nl/ovw/40/c/c00101.htm If you look at the source code there are alot of tables in there and i wont to always get the text between the <font size="2" face="Arial"> tags. With this script the current output is: array(2) { [0]=> array(0) { } [1]=> array(0) { } } Please help out, thanks.. If there is anything unclear, do say so and ill update this post. Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted October 6, 2011 Share Posted October 6, 2011 here you go, i tested this.. I believe that your biggest issue was not including the s modifier and using ".", i believe that there are spaces and or newlines being used between the tags.. $roosterPage = "http://rst-vltn.roczeeland.nl/ovw/40/c/c00101.htm"; $rooster = file_get_contents($roosterPage); preg_match_all('~<font size="2" face="Arial">(.*)</font>~is', $rooster, $matches2); print_r($matches2); Quote Link to comment Share on other sites More sharing options...
mikelmao Posted October 6, 2011 Author Share Posted October 6, 2011 o haha i cant believe it Good to know that 's' doesnt consider whitespaces as character, i should read up some more about regex, thanks for your help, it worked out for me Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted October 6, 2011 Share Posted October 6, 2011 glad i can help.. the s modifier is for the " . " character in regex, normally " .* " would grab anycharacter except spaces.. adding the s modifier allows " . " to grab spaces as well.. Quote Link to comment Share on other sites More sharing options...
mikelmao Posted October 6, 2011 Author Share Posted October 6, 2011 Aah ok, thx for the help 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.