Re: Getting source from remote file

From: Date: Thu, 06 May 2010 08:55:30 +0000
Subject: Re: Getting source from remote file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-304939@lists.php.net to get a copy of this message
On 6 May 2010 10:47, Auto-Deppe C. Hänsel <c.haensel@auto-deppe.de> wrote: > Hi guys and girls, > > okay, this is a dumbnut question I wouldn't bother asking.... but I really > did hit a spot now where I am totally wedged up in my head and can't think > straight anymore... so the, I bet easy, answer to my question escapes me. > > What I am trying to do is the following: > > Read the contents of a remote file via file() > > So I do > > $content = file($url); > > Now $content holds the HTML source of the page. > > Now this page has some DIVs in it with a class "myclass123" (just for this > purpose) > > Now I want to get the content of these divs into a variable / some > variables. No more, no less. > > Can anybody please direct me towards the answer? Damn, I must sleep more at > night, so I can think straight at work.... > > Any help is very much appreciated! Thanks! > > Chris > You could parse the document with the DOM classes. Load as a DOMDocument, then grab what's needed with the relevant methods (you can use xpath to single out your divs with the right classes). http://dk2.php.net/domdocument -- <hype> WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind Flickr: http://www.flickr.com/photos/fake51 BeWelcome: Fake51 Couchsurfing: Fake51 </hype>

« previous php.general (#304939) next »