Read in html from website?

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
Jeslyn
Forum Newbie
Posts: 6
Joined: Mon May 23, 2005 11:35 pm

Read in html from website?

Post by Jeslyn »

Hi everyone...need alittle help urgently..

I'm currently doing a program which may need to obtain real time updates on exchange rates from a certain reliable website. I know it can be done in java using openConnection() and stuff..is there a way to do it using php?

thanx alot in advance
:D
Revan
Forum Commoner
Posts: 83
Joined: Fri Jul 02, 2004 12:37 am
Location: New Mexico, USA
Contact:

Post by Revan »

ReadFile() to download a file from a site, and parse it.
fsockopen() if it's some kind of API.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Use file_get_contents() and then parse it using RegExp
Jeslyn
Forum Newbie
Posts: 6
Joined: Mon May 23, 2005 11:35 pm

Post by Jeslyn »

thanx for the reply...but i'm kinda new in this...
i can't seem to get it to work...i tried file_get_contents, fopen...etc
but the $handle which fopen returns seems to be false..

this is the website i'm trying to read..."http://www.dbs.com/ratesonline/fxbra.html"
Basically i've to read the html source of this webby into a string...
den extract what i need from it.

the extraction part should be fine...i just need to read the html source from that webby into a string...
Thanks once again
:oops:
ody
Forum Contributor
Posts: 147
Joined: Sat Mar 27, 2004 4:42 am
Location: ManchesterUK

Post by ody »

Jeslyn wrote:thanx for the reply...but i'm kinda new in this...
i can't seem to get it to work...i tried file_get_contents, fopen...etc
but the $handle which fopen returns seems to be false..

this is the website i'm trying to read..."http://www.dbs.com/ratesonline/fxbra.html"
Basically i've to read the html source of this webby into a string...
den extract what i need from it.

the extraction part should be fine...i just need to read the html source from that webby into a string...
Thanks once again
:oops:
Does the server in question have direct routing?
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

does the site owner allow this sort of thing would be my big question for you.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

after seeing this question asked about once a day i think there should be a sticky post about getting a websites content then using preg to get what you want so hopefully this question dosnt come up so often
Jeslyn
Forum Newbie
Posts: 6
Joined: Mon May 23, 2005 11:35 pm

Post by Jeslyn »

thanx for the replies...
i cld do it in java...so i dun tink it's the site's problem...

"$handle = fopen($url, 'r')" doesn't seem to work...any ideas?
:(
Jeslyn
Forum Newbie
Posts: 6
Joined: Mon May 23, 2005 11:35 pm

Post by Jeslyn »

really sorry guyz...
i realised the mistake was somewhere else...
yupz...the code works...
thanx alot everyone

:oops:
Post Reply