View Single Post
04-18-2011, 12:44 AM
#1
360 is offline 360
360's Avatar
Status: I'm new around here
Join date: Sep 2010
Location: Australia
Expertise: Design
Software: Adobe Photoshop
 
Posts: 8
iTrader: 0 / 0%
 

360 is on a distinguished road

  Old  Grabbing content (aka. page scraping) from a website

As an alternative to using an XML feed (possibly if a website doesnt offer any feeds) you can use the following method to load the website into PHP & then grab certain content:

Code:
// Create DOM from URL or file 
$html = file_get_html('http://www.google.com/');  

// Find all images 
foreach($html->find('img') as $element)
echo $element->src . '<br>'; 

// Find all links
foreach($html->find('a') as $element) 
echo $element->href . '<br>';
Note that this is not my original code, i've sourced this through google searches. Although it's definately handy so i wanted to share it with you all.

Cheers,

Thanked by 2 users:
DDS (04-18-2011), rocoso (06-09-2011)