0

How to get html source code from https? I try to use curl instead of get_file_contests, but still not get the image src

require dirname(__FILE__) . '/simple_html_dom.php';

$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'https://www.tumblr.com/');
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_BINARYTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl_handle, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1");
$query = curl_exec($curl_handle);
curl_close($curl_handle);

$html = file_get_html($query);
foreach($html->find('img') as $element) {
   echo $element->src.'<br />';
}
2
  • file_get_html() is not a function in php. itr may be file_get_contents() Commented Apr 13, 2012 at 8:47
  • @diEcho file_get_html() comes from the simple_html_dom library. Commented Apr 13, 2012 at 8:55

1 Answer 1

1

Change

$html = file_get_html($query);

to:

$html = str_get_html($query);

The file_get_html function expects a file (or a URL), not a variable.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.