我遇到的問題是如下:獲得的file_get_contents錯誤 - simple_html_dom.php XAMPP
Warning: file_get_contents(): Unable to find the wrapper "https" -
did you forget to enable it when you configured PHP? in
<b>C:\xampp\htdocs\test_crawl\simple_html_dom.php</b> on line <b>75</b><br
/>
<br />
<b>Warning</b>: file_get_contents(https://www.yahoo.com): failed to open
stream: Invalid argument in
<b>C:\xampp\htdocs\test_crawl\simple_html_dom.php</b> on line <b>75</b><br
/>
我做了一些研究,我發現了幾個職位,說取消註釋在php.ini
作品extension=php_openssl.dll
但是當我沒有和我重新開始服務器它沒有我習慣not.The腳本如下:
$url = 'https://yahoo.com'
function CrawlMe($url)
{
$html = file_get_html($url);
return json_encode($html);
}
不知道爲什麼它不工作會感謝你的幫助..
下面是一個真實示數出在$contents = file_get_contents($url, $use_include_path, $context, $offset);
function file_get_html($url, $use_include_path = false, $context=null,
$offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true,
$target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true,
$defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
{
// We DO force the tags to be terminated.
$dom = new simple_html_dom(null, $lowercase, $forceTagsClosed,
$target_charset, $stripRN, $defaultBRText, $defaultSpanText);
// For sourceforge users: uncomment the next line and comment the
// retreive_url_contents line 2 lines down if it is not already done.
$contents = file_get_contents($url, $use_include_path, $context, $offset);
// Paperg - use our own mechanism for getting the contents as we want to
control the timeout.
//$contents = retrieve_url_contents($url);
if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
{
return false;
}
// The second parameter can force the selectors to all be lowercase.
$dom->load($contents, $lowercase, $stripRN);
return $dom;
}
線75:'$內容=的file_get_contents($網址,$ use_include_path,$背景下,$偏移); ' –
...以及那些變量設置爲?如果你只是發佈所有的代碼,它會容易得多。 – miknik
這裏是[函數定義](http://sandbox.onlinephpfunctions.com/code/c86f20d4667405d27ac212a1130b9a857468e74a) –