Jump to content

Regex Reading Web Page Problem (Not doing what i want)


mikelmao

Recommended Posts

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.

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.