Page 1 of 1

How to display specific contents of a secure webpage(fopen)?

Posted: Tue Feb 12, 2008 6:33 am
by vishals81
PHP ver 5.2.5
MySQL ver 5.0.45

1)I want to call the follwing URL in PHP ---> https://www.wachovia.com.

2) The next thing I want to do is get to the specific contents of the that URL. Say for example :

Insurance on that web-page. I would like to fetch those contents from the URL and display them in a new window or redirect them to a collumn or row in a form. I am restricted to using fopen on my server and cannot use curl function.Please could you assist me on this with the help of some sample code!!! Thanks

Re: How to display specific contents of a secure webpage(fopen)?

Posted: Tue Feb 12, 2008 7:02 am
by vishals81
I have managed to open the secure website. My only concern now is to fetch specific contents from that web-page and view them. Thanks!!!

Re: How to display specific contents of a secure webpage(fopen)?

Posted: Tue Feb 12, 2008 9:37 am
by superdezign
vishals81 wrote:I have managed to open the secure website. My only concern now is to fetch specific contents from that web-page and view them.
Make use of regular expressions.

Re: How to display specific contents of a secure webpage(fopen)?

Posted: Wed Feb 13, 2008 2:39 am
by vishals81
Well I need a little assistance on this. I have many tables defined in my HTML source, however I need to extract this particular table and display the contents in a more systematic format. The table is copied for your reference below

<tbody>
<tr class="title">
<td>Bid</td>
<td>Ask</td>
<td>Reference</td>
</tr>






<tr>
<td>125.02&nbsp;</td>
<td>126.29&nbsp;</td>
<td>439.55&nbsp;</td>
</tr>
</tbody>

I need to extract the above table from the web-page using reg expression. I tried to do something like:

<?php
$data = file_get_contents('https://');
//echo $data;
$regex = "/^[table name]. */";
echo $regex;
preg_match($regex,$data,$match);
var_dump($match);

echo $match[1];
$result = $match[1];
echo $result
?>
But none of the table contents are dispalyed, instead I get this " /^[table name]. */array(0) { } " as my o/p. Could you please help me correct the above code if possible. Appreciate it!!!

Re: How to display specific contents of a secure webpage(fopen)?

Posted: Thu Feb 14, 2008 6:41 am
by vishals81
I used strip tags to get rid of the tags displayed by a webpage. Now the issue is that white space remains and I would like to eradicate that as well. Any suggestions on the sample code i need to use to perform such a function? The reason I need to get rid of the whitespace is because I am transfering data from the webpage into a database and the table in the database does not look good if there is white space present.Thanks!!!

Re: How to display specific contents of a secure webpage(fopen)?

Posted: Thu Feb 14, 2008 7:55 am
by Christopher
str_replace(), preg_replace(), trim(), etc. can be used to remove whitespace.