gpt4 book ai didi

php - Zillow - 请求被阻止,检测到爬虫

转载 作者:行者123 更新时间:2023-12-02 11:18:45 26 4
gpt4 key购买 nike

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

这是在我的本地运行但在我们的服务器中不起作用的示例代码。

echo @file_get_content("example.xml");

谢谢!

最佳答案

我非常确定 Zillow 会授予 API key 来限制任何人访问其数据,并监控正在提供的数据量。这是几乎所有公共(public) API 的标准做法。

编辑:删除了标题建议。 Zillow 希望您将 API key 作为查询字符串参数传递。 URL 看起来像这样。

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

在 php 中你可以尝试 cURLfile_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 );

您可以在 cURL 中传入很多选项,请查看此页面以进一步阅读。 http://php.net/manual/en/book.curl.php

关于php - Zillow - 请求被阻止,检测到爬虫,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28689511/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com