Quantcast
Channel: Pelle Christoffer Hagring Bjerkestrand » finn.no
Viewing all articles
Browse latest Browse all 2

Updated Finn Scraper

$
0
0

Finn recently updated their real estate listings, rendering my scraper useless.

A couple of modifications, and it’s as good as new

require_once("simple_html_dom.php");
$url = $_GET['url'];

if(strpos($url, 'http://www.finn.no') === false) {
	echo("Invalid URL");
}
else {
	$ret = array();
	
	$html = file_get_html($url);
	$price_box = $html->find('dl[class=price]',0);
	$price_box_2 = $html->find('dl[class=price]',1);
	
	/* Asking price */
	$price_suggestion = $price_box->find('dd[class=boost] span',0)->plaintext;
	if($price_suggestion != null)
		$ret['price'] = preg_replace('[\D]', '', utf8_encode($price_suggestion));
	
	/* Communal debt */
	$com_debt = $price_box->find('dd',1)->plaintext;
	if($com_debt != null)
		$ret['com_debt'] = preg_replace('[\D]', '', utf8_encode($com_debt));
		
	/* Monthly cost */
	$mnth_cost = $price_box_2->find('dd',0)->plaintext;
	if($mnth_cost != null)
		$ret['mnth_cost'] = preg_replace('[\D]', '', utf8_encode($mnth_cost));
	
	print(json_encode($ret));
}

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images