How do I get specific content from a page?

+1 John Doe · December 2, 2014
$url = (anURL);
$res = file_get_contents($url);

Let's say this link led to a profile of some guy, how would I get let's say...the description/blurb of him? Specific content..Because $res returns the whole thing.

Post a Reply


Oldest  Newest  Rating
0 Ibrahim Tuzlak · December 12, 2014
I have never done it, but I'll try to help as much as I could.

If you know exactly what website is going to be checked, you may want to inspect it (you know, browser inspector) and get to the description [html] div name. After that, use RegEx to (or any other tool that can) filter out everything in between the tag:

$url = [URL];

$res = file_get_contents($url);

$descr = [insert RegEx stuff according to the tag name];

In meantime, I'll play with this way of getting content from a website because I think it's interesting, and will link you the result if I make it.
0 Chris Sisco · December 25, 2014
I've done this with the DomDocument class. As mentioned above you will have to inspect the page to find out exactly what you are looking for.

Here is a pretty good tutorial on how to use the DomDocument class to get information from a web page.
  • 1



Server-side, HTML embedded scripting language used to create dynamic Web pages.