Getting Zillow API Data

2019-07-20 20:04发布

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

Edit 1: Error When Run On Inmotion Hosting

When I run this code on inmotion hosting server I receive :

<html><head><title>Zillow: Real Estate, Apartments, Mortgage &amp; 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 -->

Edit 2: Additional Information

I can curl the url in terminal and it works. I also can run this php in local host (XAMPP) and it works.

1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-07-20 21:03

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.

If I add a delay before I next hit to the api it seems to not throw up the captcha.

The delay seemed to be around 300 ms to get it to work.

in php

sleep(.3);

Obviously this might work for your use case, but it is one work around, as ugly as it is.

查看更多
登录 后发表回答