how to extract part of HTML page



Hi everyone,

I'm trying to write a PHP script that connects to a bank's currency convertor page using cURL and that part works fine. The issue is that I end up with a page that includes a lot of information that I don't need. Using the PHP function strip_tags I've ended with the text below and from the remaining HTML code, I'd like to extract the lines starting with "<TABLE BORDER="1" WIDTH="315">" up to its closing </TABLE> tag. How do I do this using PHP? I tried using preg_match and the like but my regex skills are pretty bad. Not too sure where to start. Could someone please provide me with some pointers?


=========================================================================================
<TABLE BORDER="0" WIDTH="600">
<tr>
<td width="148"></td>
<td width="448">some text some text some text some text some text</td>
</tr>
</TABLE>

<TABLE BORDER="0" WIDTH="600">
<TR><TD VALIGN="top" WIDTH="148">
</TD>
<TD WIDTH="448" VALIGN="top">
<TABLE BORDER="0" WIDTH="448">
<TR><TD>
some text some text some text some text some text some text some text some text some text some text.
some text some text some text some text some text
</TD></TR>
<TR><TD>
<TABLE BORDER="1" WIDTH="315"> <----- extract from here

<TR><TD>
some text some text some text some text some text
</TD>
<TD ALIGN="right">
some text some text some text some text some text
</TD></TR>
<TR><TD>
some text some text some text some text some text
</TD>

<TD ALIGN="right">
some text some text some text some text some text
</TD></TR>
<TR><TD>
some text some text some text some text some text
</TD>
<TD ALIGN="right">
some text some text some text some text some text
</TD></TR>
</TABLE> <--------- to here
</TD></TR>
<TR><TD>
a {
color:blue;
}
some text some text some text some text some text
some text some text some text some text some text some text some text some text some text some text
some text some text some text some text some text some text some text some text some text some text
</TD></TR>
<TR><TD>
some text some text some text some text some text
some text some text some text some text some text some text some text some text some text some text some text some
</TD></TR>
</TABLE>
</TD></TR>
</TABLE>
<br>
=========================================================================================


Thanks
Eric

.



Relevant Pages

  • Re: HELP: strange php behavior downloading html
    ... problem in less than an hour, using cURL with PHP. ... Here is the function I wrote to download a uri into a file (following ... all redirects, ignoring old cookies, and passing set cookies to redirects): ...
    (comp.lang.php)
  • Re: HTTP POST from PHP using a link
    ... I have a php script that is passing a list of cases from on page to ... It looks like I can do this with cURL, but this script will run on ... I found a few posts that say this can be done with PHP and javascript, ...
    (comp.lang.php)
  • Re: HTTP POST from PHP using a link
    ... I have a php script that is passing a list of cases from on page to ... It looks like I can do this with cURL, but this script will run on ... I found a few posts that say this can be done with PHP and javascript, ... just send the key back and query the database again. ...
    (comp.lang.php)
  • Re: HTTP POST from PHP using a link
    ... I have a php script that is passing a list of cases from on page to ... It looks like I can do this with cURL, but this script will run on ... I found a few posts that say this can be done with PHP and javascript, ... System Administrator / Web Developer ...
    (comp.lang.php)
  • CLI CURL problem, happens only on the CLI?
    ... I have a php script that runs from command line and makes an https ... request to paypal, using curl. ... It fails if I run it from CLI. ...
    (comp.lang.php)