Sửa lỗi Simple html dom file_get_html not working - is there any workaround? (ok)
https://stackoverflow.com/questions/18667441/simple-html-dom-file-get-html-not-working-is-there-any-workaround
<?php
include('simple_html_dom.php');
// Report all PHP errors (see changelog)
$base = 'https://mediamart.vn';
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_URL, $base);
curl_setopt($curl, CURLOPT_REFERER, $base);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$str = curl_exec($curl);
curl_close($curl);
// Create a DOM object
$html_base = new simple_html_dom();
// Load HTML from a string
$html_base->load($str);
//get all category links
foreach($html_base->find('a') as $element) {
echo "<pre>";
print_r( $element->href );
echo "</pre>";
}
$html_base->clear();
unset($html_base);
?>4 Answers

PreviousSửa lỗi Warning: file_get_contents(): stream does not support seeking (ok)NextHướng dẫn lấy tin khuyến mãi, khuyến mại website hc.com.vn (ok)
Last updated
