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
How to display specific contents of a secure webpage(fopen)?
Moderator: General Moderators
Re: How to display specific contents of a secure webpage(fopen)?
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!!!
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: How to display specific contents of a secure webpage(fopen)?
Make use of regular expressions.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.
Re: How to display specific contents of a secure webpage(fopen)?
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 </td>
<td>126.29 </td>
<td>439.55 </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!!!
<tbody>
<tr class="title">
<td>Bid</td>
<td>Ask</td>
<td>Reference</td>
</tr>
<tr>
<td>125.02 </td>
<td>126.29 </td>
<td>439.55 </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)?
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!!!
- 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)?
str_replace(), preg_replace(), trim(), etc. can be used to remove whitespace.
(#10850)