async def candidate_to_notification(self, candidate) -> Notification: url = f"https://www.century21.fr/trouver_logement/detail/{self.get_candidate_native_id(candidate)}" resp = await self.client.patient_fetch( HTTPRequest(method="GET", url=url)) soup = BeautifulSoup(resp.body.decode(), 'lxml') rooms_el = [ i for i in soup.select('#ficheDetail .titreDetail') if 'Nombre de pièces' in i.text ] return Notification( price=soup.select_one('.tarif b').text.strip(), area=float( re.search('((\d|,)*?) m²', candidate.select('.tw-text-sm') [1].text.strip()).group(1).replace(",", ".")), location=candidate.select('.tw-text-sm')[0].text.strip(), url=f"https://www.century21.fr{candidate.select_one('a')['href']}", pics_urls=[ f"https://www.century21.fr{i['href']}" for i in soup.select('.zone-galerie a[href]') ], description=soup.select_one( '.fondAnnonce .tw-text-justify').text.strip(), rooms=self.get_nb_rooms(rooms_el, soup))
async def candidate_to_notification(self, candidate) -> Notification: return Notification( price=candidate.get('price')[0], location=read_prop(candidate, 'location', 'zipcode'), area=float({e['key']: e['value'] for e in candidate['attributes']}.get('square')), url=candidate.get('url'), pics_urls=read_prop(candidate, 'images', 'urls_large'), description=candidate.get('body').strip() )
async def candidate_to_notification(self, candidate) -> Notification: return Notification(price=candidate['price'], location=candidate['postalCode'], area=candidate['surfaceArea'], url="https://www.bienici.com/annonce/location/" + self.get_candidate_native_id(candidate), pics_urls=[p['url'] for p in candidate['photos']], description=candidate.get('description'), rooms=candidate.get('roomsQuantity'))
def test_notification(): n1 = Notification(id="one", source="source_one", price=1.23, location="loc_one", area=3.21, url="url_one", pics_urls=["pic_one"]) n2 = Notification(id="one", source="source_two", price=2.23, location="loc_two", area=1.21, url="url_two", pics_urls=["pic_two"]) assert n1 == n2, "Assert equals" assert hash(n1) == hash(n2), "Assert hash"
async def candidate_to_notification(self, c) -> Notification: return Notification( description=c.get('description'), rooms=c.get('roomsCount'), floor=c.get('floorNumber'), price=c['price'], location=read_prop(c, 'viewData', 'localityName'), area=c['surface'], url=f"https://www.avendrealouer.fr/{c['realms']['aval']['url']}", pics_urls=([i['url'] for i in c['medias']['photos']] if read_prop( c, 'medias', 'photos') else []))
async def candidate_to_notification(self, c) -> Notification: main_content = await self.client.patient_fetch( HTTPRequest(method='GET', url=read_prop(c, 'links', 'self'))) main_content = main_content.json() return Notification( area=read_prop(c, 'surface'), location=read_prop(c, 'address', 'postcode'), price=read_prop(c, 'price'), url=read_prop(c, 'links', 'self'), pics_urls=read_prop(c, 'photos'), description=main_content.get('description'), rooms=main_content.get('rooms'), floor=main_content.get('floor'), )
async def candidate_to_notification(self, c) -> Notification: res = await self.client.patient_fetch( HTTPRequest( method='GET', headers=self.headers, url= f'https://api-seloger.svc.groupe-seloger.com/api/v1/listings/{c["id"]}' )) res = res.json() return Notification(price=c.get('price'), location=c.get('zipCode'), area=c.get('livingArea'), url=c.get('permalink'), pics_urls=c.get('photos'), description=res.get('description'), rooms=res.get('rooms'))
async def candidate_to_notification(self, c): if self.filter.furnished and not read_prop(c, 'properties', 'furnished'): return None return Notification( price=c['pricing']['amount'], location=c['location']['city']['postCode'], area=c['properties']['area'], url=c['info']['link'], pics_urls=[ i.replace('width=[WIDTH]&height=[HEIGHT]&scale=[SCALE]', 'width=800&height=600&scale=1') for i in c['pictures'] ], description=read_prop(c, 'info', 'text').strip(), rooms=read_prop(c, 'properties', 'rooms'))
async def candidate_to_notification(self, c) -> Notification: res = await self.client.patient_fetch( HTTPRequest( method='GET', url=f'https://www.orpi.com/api/estate/{c["reference"]}', headers=self.headers)) res = res.json() return Notification( price=c['price'], area=c['surface'], location=c['locationDescription'], url=f"https://www.orpi.com/annonce-location-{c['slug']}", pics_urls=c.get('images'), description=res.get('longAd'), rooms=res.get('nbRooms'), floor=res.get('storyLocation'), )
async def candidate_to_notification(self, candidate) -> Optional[Notification]: candidate_location = self.paparr_to_arr( read_prop(candidate, '_embedded', 'place')[0]['id']) if candidate_location not in self.filter.arrondissements: return None det = await self.client.patient_fetch( HTTPRequest(method='GET', url=candidate['_links']['self']['href'])) det = det.json() if not read_prop(det, '_embedded', 'photo'): return None return Notification(price=candidate['prix'], location=str(candidate_location), area=candidate['surface'], url=candidate['_links']['desktop']['href'], pics_urls=[ i['_links']['self']['href'] for i in read_prop(det, '_embedded', 'photo') ], description=det.get('texte'), rooms=det.get('nb_pieces'))
async def candidate_to_notification(self, cid): url = f"https://immobilier.lefigaro.fr/annonces/annonce-{cid}.html" resp = await self.client.patient_fetch( HTTPRequest( method="GET", url=f"https://immobilier.lefigaro.fr/rest/iClassified?id={cid}" )) info = BeautifulSoup(resp.body.decode(), 'lxml') price = info.select_one('price').text if float(price) > self.filter.max_price: return return Notification( price=price, location=info.select_one('localisation postalcode').text, area=info.select_one('characteristics surface').text, url=url, pics_urls=[ i['url'].replace('img/l', 'img/xxl') for i in info.select('photos photo') ], description=info.select_one('description').text.strip(), rooms=int(info.select_one('nbrooms').text), floor=info.select_one('floor').text)
def create_candidate(self, i): return Notification( id=i['data-classified-id'], location=i['data-agency-postal-code'], price=i.select('.price-label')[0].text.strip().split('\n')[0])