How can I get url content to variable?

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
nadavvin
Forum Commoner
Posts: 68
Joined: Wed Sep 06, 2006 6:05 am

How can I get url content to variable?

Post by nadavvin »

Hello

I want to get html content from other URL to variable.
I know that with XML I can use in domxml but It's not xml and I want to get it as string.

How do I do this?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

fopen() or maybe file_get_contents() (php5)
User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

Post by akimm »

Why exactly do you ask, I am confused as to what you exactly want to do.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

he wants to get the content from another url into a variable... :roll:

Code: Select all

// Loads contents of site into a variable
$contents_of_devnet = file_get_contents('http://www.forums.devnetwork.net');
User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

Post by akimm »

Thats neat lol. Altho it scares me if it works, because of how easily content can be stolen 8O
nadavvin
Forum Commoner
Posts: 68
Joined: Wed Sep 06, 2006 6:05 am

Post by nadavvin »

yes, It's what I want.


There is a forum which I like but there isn't any RSS with it.
I want to get the forum page and make it RSS.

Thanks for your help.
nadav
Last edited by nadavvin on Mon Sep 18, 2006 1:58 pm, edited 1 time in total.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

It's no different than clicking "view source" except it is being done by php instead of your mouse... nothing really to worry about.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

The Ninja Space Goat wrote:file_get_contents() (php5)
fyi, file_get_contents() is php4, file_put_contents() is php5
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

oh wow... didn't know that.. thanks jcart! :wink:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

nadavvin wrote:yes, It's what I want.


There is a forum which I like but there isn't any RSS with it.
I want to get the forum page and make it RSS.

Thanks for your help.
nadav
Have you asked them about adding an RSS feed from it?
nadavvin
Forum Commoner
Posts: 68
Joined: Wed Sep 06, 2006 6:05 am

Post by nadavvin »

I think that I send them request to add RSS and they didn't return any answer.
Post Reply