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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vishals81
Forum Newbie
Posts: 6
Joined: Tue Feb 12, 2008 6:18 am

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

Post 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
vishals81
Forum Newbie
Posts: 6
Joined: Tue Feb 12, 2008 6:18 am

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

Post 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!!!
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

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

Post 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.
vishals81
Forum Newbie
Posts: 6
Joined: Tue Feb 12, 2008 6:18 am

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

Post 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!!!
vishals81
Forum Newbie
Posts: 6
Joined: Tue Feb 12, 2008 6:18 am

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

Post 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!!!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

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

Post by Christopher »

str_replace(), preg_replace(), trim(), etc. can be used to remove whitespace.
(#10850)
Post Reply