获取Zillow API数据 [英] Getting Zillow API Data
问题描述
即使我觉得我正确使用了他们的API,我也无法访问任何zillow信息.有帮助吗?
I can't access any zillow information even though I feel that I am using their API correctly. Any help?
$zillow_id = '<MY ZPID>';
$search = "2114 Bigelow Ave";
$citystate = "Seattle, WA";
$address = urlencode($search);
$citystatezip = urlencode($citystate);
$url = "http://www.zillow.com/webservice/GetSearchResults.htm?zws-id=$zillow_id&address=$address&citystatezip=$citystatezip";
$result = file_get_contents($url);
//$data = simplexml_load_string($result);
print_r($result);
在Inmotion主机上运行时出错
Edit 1: Error When Run On Inmotion Hosting
当我在inmotion托管服务器上运行此代码时,我收到:
When I run this code on inmotion hosting server I receive :
<html><head><title>Zillow: Real Estate, Apartments, Mortgage & Home Values in the US</title><meta http-equiv="X-UA-Compatible" content="IE=8, IE=9"/><meta name="ROBOTS" content="NOINDEX, NOFOLLOW"/><link href="//fonts.googleapis.com/css?family=Open+Sans:400&subset=latin" rel="stylesheet" type="text/css"/><link href="http://www.zillowstatic.com/vstatic/069be37/static/css/z-pages/captcha.css" type="text/css" rel="stylesheet" media="screen"/><script language="javascript">
function onReCaptchaLoad() {
window.reCaptchaLoaded = true;
}
window.setTimeout(function () {
if (!window.reCaptchaLoaded) {
document.getElementById('norecaptcha').value = true;
document.getElementById('captcha-form').submit();
}
}, 5000);
</script></head><body><main class="zsg-layout-content"><div class="error-content-block"><div class="error-text-content"><!-- <h1>Captcha</h1> --><h5>Enter the characters in the images to continue.</h5><div id="content" class="captcha-container"><form method="POST" action="" id="captcha-form"><script type="text/javascript">
var RecaptchaOptions = {"theme":"white","lang":"en-US"};
</script>
<script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6Lf2nvMSAAAAAMQ5p6WlAfDEixMdOQgJsij-3_ud" onload="onReCaptchaLoad()"></script>
<br/><input id="dest" name="dest" type="hidden" value="ognl:originalDestination"/><input id="norecaptcha" name="norecaptcha" type="hidden" value="false"/><button type="submit" class="zsg-button zsg-button_primary">Submit</button></form><img src="http://www.zillowstatic.com/static/logos/logo-65x14.png" width="65" alt="Zillow" height="14"></img></div></div></div></main></body></html><!-- H:025 T:1ms S:1494 R:Sat Mar 28 09:57:53 PDT 2015 B:4.0.13785-master.359ed12-HOTFIX-824c097-20150326.222442.359ed1207efb984585ffa75531a9fba99c178f3e.20150326163022395-origin/master -->
其他信息
我可以在终端中卷曲URL,它可以正常工作.我也可以在本地主机(XAMPP)中运行此php,它可以工作.
I can curl the url in terminal and it works. I also can run this php in local host (XAMPP) and it works.
推荐答案
我也遇到了这个问题.当我对zillows api进行连续点击时,我正在点击它.例如,搜索地址,然后立即获取该属性的补偿.
I ran into this too. I was hitting it when I was doing serial hits to zillows api. For example, search for address and then get comps right away for that property.
如果我在下次点击api之前添加了延迟,则似乎没有抛出验证码.
If I add a delay before I next hit to the api it seems to not throw up the captcha.
要使其正常工作,延迟似乎在300毫秒左右.
The delay seemed to be around 300 ms to get it to work.
在php
sleep(.3);
显然,这可能适用于您的用例,但这是一个变通方法,虽然很丑陋.
Obviously this might work for your use case, but it is one work around, as ugly as it is.
这篇关于获取Zillow API数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!