Jump to content

[SOLVED] read html page


ravi181229

Recommended Posts

Hi,

 

I like to have a php script which reads html page and get me the information.

The link for the html page is http://www.nowlive.com/schedule.aspx

I want to fetch the following information from the link above(see the view source):

Time which is in <span id="ctl00_MainContent_RepeaterSchedule_ctl01_lblDate">Tue, 5:00 PM PST</span>

and parameter from ddrivetip() function for all the event/show.

 

The info is in <tr></tr> block for all the event/show:

 

<tr>

  <td style="width:3px;"></td>

  <td height="20" align="left" style="width: 125px; color:#eeeeee; font-size:10px;">

  <span id="ctl00_MainContent_RepeaterSchedule_ctl06_lblDate">Tue, 5:00 PM PST</span>

  </td>

  <td align="left" style="width: 400px;">

    <div id="ctl00_MainContent_RepeaterSchedule_ctl06_pnlLiveTitle">

      <a style="color:White; font-size:10px;" href="/QuietontheSet" onmouseout="hideddrivetip()" onmouseover="ddrivetip('<table cellpadding=3 border=0 width=300 height=120><tr><td valign=top width=80><img src=http://media2.nowlive.com/member_image.asp?file=/images/members/100288149/100288149_av.jpg width=100 height=100 class=thumb /></td><td valign=top width=*> <a href=#><strong>White Soaring Eagle Inter</strong></a><br /><img id=rating src=/images/flag-M.gif vspace=4 /><br />White Soaring Eagle, formerly known as Two Feathers is a musician with a flare for eclectic sounds.  Being a descendant of the Seihlagee Nation (Cherokee), he’s always enjoyed music of most kinds from</td></tr></table>')">

      White Soaring Eagle Inter

      </a>

    </div>

  </td>

</tr>

 

Please help me.

 

Thanks,

Ravi

 

 

Link to comment
https://forums.phpfreaks.com/topic/131338-solved-read-html-page/
Share on other sites

Easy - if you know how to do it ;):

 

<?php
$source = file_get_contents('http://www.nowlive.com/schedule.aspx');
preg_match_all('~id="ctl\d+_MainContent_RepeaterSchedule_ctl\d+_lblDate">([^<]*).+?ddrivetip\(\'([^\']*)~is', $source, $matches);
//remove full pattern matches from $matches
array_shift($matches);
//have a look at $matches
echo '<pre>', print_r($matches, true), '</pre>';
?>

 

Important parts of the regular expression (first parameter in preg_match_all()):

 

\d+ matches 1 or more digits.

([^<]*) matches any character NOT a < 0 or more times, and saves match in $matches.

.+? matches any character 1 or more times. Ungreedy, so it stops matching when the following string (ddrivetip..) is found.

([^\']*) matches any character NOT a ' 0 or more times, and saves the match in $matches.

is are pattern modifiers, making the search case insensitive and dots match new lines also.

 

Just ask if you need help rearranging the data in $matches.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.