抓取带有子域名的.net站点



我正在尝试用php curl抓取。net网站。我试图抓取的网站是

http://waltham.patriotproperties.com

我可以爬网站。

但是当我试图抓取像

这样的内部页面时
http://waltham.patriotproperties.com/about.asp

或该子域内的任何其他页面它会给出如下错误

The page cannot be displayed because an internal server error has occurred.1

我使用的代码如下

$ch = curl_init();
$urlLogin   =   "http://www.waltham.patriotproperties.com";
curl_setopt($ch, CURLOPT_URL, $urlLogin);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
//curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
$data = curl_exec($ch);
echo $data; 

代码适用于

http://waltham.patriotproperties.com/

但不适合

http://waltham.patriotproperties.com/search.asp
http://waltham.patriotproperties.com/summary.asp

表示此子域内的任何url。子域内url的错误是

HTTP/1.1 500 Internal Server Error
Content-Type: text/html
Server: Microsoft-IIS/7.5
Date: Wed, 05 Jun 2013 16:33:57 GMT
Content-Length: 75 

你的起点是:

$urlLogin   =   "http://www.waltham.patriotproperties.com";

但是搜索页面的链接在:

http://waltham.patriotproperties.com/search.asp

如果你浏览到那个URL,你会看到内容;如果您将www.添加到URL的开头,它就可以工作。

编辑添加 -如果他们有一个可以使用的API,这会变得容易得多。

最新更新