I'm trying to start a web crawler. Below is the starting code,
<?php
$start = "https://www.yocale.com/Search?latitude=29.748093&longitude=-95.37127699999996";
function follow($url)
{
$content = file_get_contents($url);
$content = str_replace('src="/', 'src="https://www.yocale.com/', $content);
$content = str_replace('href="/', 'href="https://www.yocale.com/', $content);
$content = str_replace('src="https://www.yocale.com//maps.googleapis.com', 'src="//maps.googleapis.com', $content);
$content = str_replace("url: '/", "url: 'https://www.yocale.com/", $content);
$content = str_replace("= '/", "= 'https://www.yocale.com/", $content);
echo $content;
}
follow($start);
From the given code, it will successfully render the html in the browser and call files that is required such as javascript.
Part of the javascript is the ajax call using this request
https://www.yocale.com/Search?distance=25km&latitude=29.748093&longitude=-95.37127699999996&_=1525228859581
It doesn't fetch any data, I know it has to do with CORS, and it is in the log,
Failed to load https://www.yocale.com/Search?distance=25km&latitude=29.748093&longitude=-95.37127699999996&_=1525228859581: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://search.oo' is therefore not allowed access.
Among other request such as fonts
Is there a way to crawl this page that render some of the data using ajax or similar in the browser using php?