danield-griffiths/portal-amalgamator

一个用于在多个房产门户中搜索属性的工具

dev-master 2021-07-04 22:16 UTC

This package is auto-updated.

Last update: 2024-08-05 05:01:00 UTC


README

一个用于从多个房产门户搜索和汇总房产信息的库。

注意:此库从房产门户抓取信息,请注意,如果房产门户更新了其网站结构,它可能无法正常工作。

为什么使用这个库?

这个库最初是为了帮助我寻找新家而创建的。我使用它定期搜索新房产,并在新房产可用时通过Slack消息通知我。租房就像热蛋糕一样抢手,这让我有机会提前预约看房。😎

当前支持的门户

  • RightMove
  • Zoopla
  • OnTheMarket

安装

composer require daniel-griffiths/portal-amalgamator dev-master

使用方法

<?php

require __DIR__.'/../vendor/autoload.php';

use DanielGriffiths\PortalAmalgamator\{
	PortalAmalgamator,
	Portals\OnTheMarket,
	Portals\Rightmove,
	Portals\Zoopla
};

// create a new instance of the amalgamator
// feel free to add or remove portals as needed
$portals = new PortalAmalgamator(
    new OnTheMarket,
    new Rightmove,
    new Zoopla
);

// search across all portals using an array 
// of search parameters
$properties = $portals->search([
	'type' => 'rent',
	'location' => 'cardiff',
	'maxprice' => 800,
	'minprice' => 1,
	'maxbedrooms' => 2,
	'minbedrooms' => 1,
])->orderBy('price')->get();

// we now have an array of properties from every portal
var_dump($properties);

过滤器

可以在 search 方法中传递各种过滤器,这些过滤器可用于缩小搜索范围,并仅返回符合指定标准的房产。

以下是支持的过滤器完整列表:

属性响应格式

完成搜索后,将返回一组属性。为了参考,以下提供了一个示例属性(以json格式编码):

{
	"image": "https://lid.zoocdn.com/354/255/abddb686034ea1ff19b6c0de370b8362520a88c2.jpg",
	"title": "1 bed flat to rent",
	"address": "Alma Road, Clifton, Bristol BS8",
	"description": "A one bedroom unfurnished apartment in clifton. A lovely light first floor flat with a large lounge and dining room area. Double bedroom. Separate kitchen with fridge/freezer, cooker and washing machine supplied. Bathroom with shower. Large storage ...",
	"price": "£800 pcm (£185 pw)",
	"link": "https://www.zoopla.co.uk/to-rent/details/45972752?search_identifier=cca03c7417fcf5ebf0b2af63779d4678",
	"source": "Zoopla"
}