我试图使用Zillow API.实际上,它正在我的本地工作并返回我需要的所有数据但是当我尝试在我们的托管中发布它时,API返回"请求被阻止,已检测到爬虫".
这是在我的本地但不在我们的服务器中工作的示例代码.
echo @file_get_content("example.xml");
Run Code Online (Sandbox Code Playgroud)
谢谢!
我非常确定Zillow会授予API密钥以限制任何人访问他们的数据,并监控正在提供的数据量.这是几乎所有公共API的标准做法.
编辑:删除标题建议.Zillow希望您将API密钥作为查询字符串参数传递.URL看起来像这样.
http://www.zillow.com/webservice/GetDemographics.htm?zws-id
<ZWSID>&state=WA&city=Seattle&neighborhood=Ballard
在PHP中你可以尝试cURL或file_get_contents:一个cURL示例:
$apiKey = qadsf78asdfjkasdjf-yourAPIKey
$url = 'http://www.zillow.com/webservice/GetDemographics.htm?zws-id=' . $apiKey .
'&state=TX&city=Austin';
$ch = curl_init($url);
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
print_r($response);
curl_close( $ch );
Run Code Online (Sandbox Code Playgroud)
您可以在cURL中传递很多选项,请查看此页面以供进一步阅读.http://php.net/manual/en/book.curl.php
| 归档时间: |
|
| 查看次数: |
3823 次 |
| 最近记录: |