Jump to content


Photo

*SOLVED* GET WEBPAGE CONTENTS


  • Please log in to reply
4 replies to this topic

#1 BladeMetal

BladeMetal
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 12 April 2006 - 08:39 AM

I know that such a function exists to pull the source code off a website. I've used it before. However, I now can find the function no matter how hard I try. Any help greatly appreciated.

And before someone asks, this is not for a malicious purpose. Its just to get data from a website and I have permission to pull it off the source.

Thanks in advance!
-BladeMetal

#2 bonaparte

bonaparte
  • Members
  • PipPipPip
  • Advanced Member
  • 44 posts
  • Location#172, I Floor, 'Hamsashree', Defence Colony, Sahakaranagar, Bangalore, India

Posted 12 April 2006 - 08:56 AM

[!--quoteo(post=363928:date=Apr 12 2006, 03:39 AM:name=BladeMetal)--][div class=\'quotetop\']QUOTE(BladeMetal @ Apr 12 2006, 03:39 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I know that such a function exists to pull the source code off a website. I've used it before. However, I now can find the function no matter how hard I try. Any help greatly appreciated.

And before someone asks, this is not for a malicious purpose. Its just to get data from a website and I have permission to pull it off the source.

Thanks in advance!
-BladeMetal
[/quote]

If you are looking to pull the HTML source off the web site use

[a href=\"http://php.net/file\" target=\"_blank\"]http://php.net/file[/a]



#3 BladeMetal

BladeMetal
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 12 April 2006 - 09:09 AM

thanks, that worked a treat!

Now I have one more issue. This is my code:
<?php
$website = file_get_contents("http://www.website.com");
print $website;
?>
This executes the HTML, but I would like it to display the HTML source on the screen as text rather than trying to display the original site.
If this is possible let me know. Thanks.

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 12 April 2006 - 09:26 AM

Yes use htmlentites:
print htmlentities($website);


#5 BladeMetal

BladeMetal
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 12 April 2006 - 09:41 AM

Hi,
Thanks heaps. Just what I needed!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users