2014-06-10 52 views
-5

我需要從ASPX頁面的HTML代碼烴源如實例可以使用Go daddy link從aspx頁面使用php獲取html代碼?

我曾嘗試和捲曲的file_get_contents BUI它dons't工作。 通過設置用戶代理嘗試cURL。 file_get_contents顯示已達到重定向限制!

$url = 'godaddy.com/hosting/website-builder.aspx?ci=88060'; 
$user_agent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36 OPR/22.0.1471.40 (Edition Next)"; 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,$url); 
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
$result=curl_exec($ch); 
curl_close ($ch); 
echo "Results: <br>".$result; 
+0

你到底想要的是不明確...... –

+0

我想從 – lubuger

+0

.aspx頁的HTML代碼這個問題是題外話,因爲OP沒有做任何研究他自己。 –

回答

0

如果你想要得到的只是特定網站的純HTML。您可以在這一個上使用file_get_contents(),然後使用htmlentities()。考慮下面這個例子:

<?php 

$url = 'https://ph.godaddy.com/hosting/website-builder.aspx?ci=88060'; 
$contents = htmlentities(file_get_contents($url)); 
echo $contents; 

?> 

Sample Output

+0

這就是我所擔心的,ty – lubuger

0

您可以做的唯一事情就是查看已處理的輸出爲html和css。

右鍵 - >查看源代碼

但是,您將無法看到ASPX源代碼。

0

使用CURL讀取遠程URL以獲取HTML。

<?php 
$url = "http://godaddy.com/hosting/website-builder.aspx?ci=88060"; 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
$output=curl_exec($ch); 
echo $output; 
?> 

How to get Content ot Remote HTML page

+0

我試過這個,文件獲取內容顯示重定向限制達到了,用上面的這一個代碼顯示空白頁面的文字對象移動到這裏! – lubuger

+0

使用CURLOPT_RETURNTRANSFER選項,如http://stackoverflow.com/questions/12164196/warning-file-get-contents-failed-to-open-stream-redirection-limit-reached-ab – Alex

+0

我也試過這個,同樣的對象轉移到了這裏。 – lubuger