我想爲95%的站點file_get_content回覆站點數據&,curl工作得很好,但對於少數站點來說,它無法工作,無論我嘗試什麼。我試圖定義適當的用戶代理,將SSL驗證更改爲false,但沒有任何工作。但是wget的與SSL支持編譯file_get_contents,curl,wget失敗,403響應
測試網站,它失敗,禁止https://norskbymiriams.dk/
wget的是無法複製SSL站點。與wget的-V
檢查我想這些codes.none工作了這一特定的網站
file_get_contents
$list_url = "https://norskbymiriams.dk/";
$html = file_get_contents($list_url);
echo $html;
curl
$handle=curl_init('https://norskbymiriams.dk');
curl_setopt($handle, CURLOPT_HEADER, true);
curl_setopt($handle, CURLOPT_VERBOSE, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36");
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);
$content = curl_exec($handle);
echo $content;
任何幫助將是巨大的
其簡單的HTTP狀態代碼403意味着你沒有訪問/權限使用/得到它.. –
@AlwaysSunny其從瀏覽器 – Steeve
@Steeve我認爲你是被封IP(IP和訪問的幾個因爲它在瀏覽器中工作)。我測試了你的代碼(從$ handle line開始的代碼,它的功能非常好,當我調用它時,我得到了200 OK。 – besciualex