房地产数据
realestate-data的Python项目详细描述
房地产数据
一个从非官方网站real estate.com.au获取房地产数据的工具 “API”。
安装
pip install realestate-data
用法
构建示意图以表示您要搜索的查询。
见here 有关可用选项,或查看./realestate_data/schematics.py
下面创建一个表示
- 待售单元和公寓
- 在墨尔本维多利亚,3000
- 周边郊区
- 价格在50万至100万美元之间
- 最少1个停车位
- 至少一间浴室
- 至少两间卧室
>>>fromrealestate_dataimportSearch,Locality,PriceRange,Filters>>>>>>p=PriceRange()>>>p.minimum=500000>>>p.maximum=1000000>>>>>>l=Locality()>>>l.locality='Melbourne'>>>l.subdivision=Locality.SUBDIVISION_VIC>>>l.postcode='3000'>>>>>>f=Filters()>>>f.property_types=[Filters.PROPERTY_TYPE_APARTMENT,Filters.PROPERTY_TYPE_UNIT]>>>f.surrounding_suburbs=True>>>f.minimum_bedrooms=2>>>f.minimum_bathrooms=1>>>f.minimum_parking_spaces=1>>>f.price_range=p>>>>>>s.channel=Search.CHANNEL_BUY>>>s.localities=[l]>>>s.filters=f
对搜索对象调用validate()以确保其有效。它会回来的 如果有效则为零,如果无效则为错误
>>>s.validate()
调用@primitive()查看搜索对象
>>>s.to_primitive(){'channel':'buy','localities':[{'locality':'Melbourne','subdivision':'VIC','postcode':'3000'}],'filters':{'property-types':['apartment','unit'],'minimum-bedrooms':1,'minimum-bathrooms':1,'minimum-parking-spaces':1,'surrounding-suburbs':True,'price-range':{'minimum':500000,'maximum':1000000}}}
将创建的搜索对象传递到分页结果生成器。发电机 生成从每个页面请求返回的json。
>>>fromrealestate_dataimportpaged_results>>>paged_data=[pageforpageinpaged_results(s)]
或者您可以随心所欲地使用生成器
>>>paged_data=paged_results(s)>>>page_one=next(paged_data)>>>page_two=next(paged_data)
>>>forpageinpaged_results(s):>>>print(page)
待办事项
- 测试
作者
杰里米·斯托尔storerjeremy@gmail.com