2

我试图使用 Zillow API。实际上,它正在我的本地工作并返回我需要的所有数据,但是当我尝试在我们的主机中发布它时,API 返回“请求被阻止,检测到爬虫”。

这是在我的本地工作但在我们的服务器中工作的示例代码。

echo @file_get_content("example.xml");

谢谢!

4

2 回答 2

5

Im pretty sure Zillow grants an API key to restrict anyone from accessing their data, and to monitor how much data is being served. This is standard practice for just about any public API.

EDIT: Removed header suggestion. Zillow wants you to pass in the API key as a query string parameter. The URL would look something like this.

http://www.zillow.com/webservice/GetDemographics.htm?zws-id <ZWSID>&state=WA&city=Seattle&neighborhood=Ballard

In php you could try cURL or file_get_contents: A cURL example:

$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 ); 

You can pass in a lot of options in cURL, check this page for further reading. http://php.net/manual/en/book.curl.php

于 2015-02-24T07:32:20.680 回答
0

如果您使用的是 vpn,Zillow 似乎会返回该爬虫消息。

于 2016-10-21T20:05:48.300 回答