-2

I wants to create a php script for alerts from my work website when new notice is published, so following the page url

http://www.mahapwd.com/nit/ueviewnotice.asp?noticeid=1767

from this page i want a variable for Date & Time of Meeting (Date and time seperately two variables) Place of Meeting and Published On please help me to create a perfect php script.

I tried to create following script but it gives to many errors

<?php
$url1 = "http://www.mahapwd.com/nit/ueIndex.asp?district=12";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
preg_match("/href=(.*)\", $data, $urldata);
$url2 = "http://www.mahapwd.com/nit/$urldata[1];
curl_setopt($ch, CURLOPT_URL, $url2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data2 = curl_exec($ch);
preg_match("/Published On:</b>(.*)<\/font>", $data, $pubDt);
$PubDate = $pubDt[1];
preg_match("/Time of Meeting:</b>(.*)&nbsp", $data, $MtDt);
$MeetDate = $MtDt[1];
preg_match("/Time of Meeting:</b>$MtDt[1]&nbsp(.*)</font>", $data, $MtTime);
$MeetTime = $MtTime[1];
preg_match("/Place of Meeting:</b>(.*)<\/font>", $data, $pubDt);
$PubDate = $pubDt[1];
?>

1 Answers1

1

Hello i have done simple code for you. You can download simple_html_dom.php from http://simplehtmldom.sourceforge.net/

 require_once "simple_html_dom.php";
 $url='http://www.mahapwd.com/nit/ueviewnotice.asp?noticeid=1767';


//parse url
for ($i=0;$i<1;$i++) {
$html1 = file_get_html($url);
if(!$html1){  echo "no content";    }
else {
//here is parsed html 
$string1 = $html1;

//now you need to find table
  $element1=$html1->find('table'); 
  //here is a table you need
 $input=$element1[2];
 //now you can select row from here 
foreach($input->find('td') as $element) {

  //in here you can find name than save it to database than check it
  } 


 }

}
ganaa
  • 167
  • 2
  • 12