Leo Maximus
Leo Maximus

Reputation: 23

Using cURL or DOM to webscrape

I've been working on this for about four hours and have been all over the internet trying to understand it, so please be gentle.

I'd like to display a div from an external source on my php page. I've tried usingfile_get_dom, simplexml_load_file, file_get_contents with preg_match_all, then printed them on my page, but they don't work. cURLing is over my head from what I have seen and can't understand any of it, but I've been told it is the best way to do it. They all result in various errors when all I want is to grab the contents of an external div. What should I do?

An example would be scraping the div id='hmenus' on this page, then displaying it on my local page.

Thanks!

Upvotes: 0

Views: 88

Answers (1)

Rob
Rob

Reputation: 12872

If cURL is over your head then perhaps try Simple HTML DOM

$html = file_get_html($url);
echo $html->find('div[id=hmenus]', 0);

Upvotes: 1

Related Questions