Skip to content

Instantly share code, notes, and snippets.

@lushkovsky-s
Created October 7, 2019 15:07
Show Gist options
  • Save lushkovsky-s/a82d01815f43e1ab3964aa36b0377710 to your computer and use it in GitHub Desktop.
Save lushkovsky-s/a82d01815f43e1ab3964aa36b0377710 to your computer and use it in GitHub Desktop.
Parse object info from domofond.ru
var link = window.location.href
var address = document.evaluate('//*[@href="#item-location"]', document)
.iterateNext()
.innerText
.replace('проспект', 'пр.')
.replace('Ленинградская область,', '')
.replace(', Санкт-Петербург', '')
.replace('посёлок', 'пос.')
.replace('район', 'р-н')
.replace(' ', '')
var price = parseInt(document.evaluate('//*[contains(@class, "information__price")]/span', document).iterateNext().innerText.replace('₽', '').replace(' ', ''))
var deposit = parseInt(document.evaluate('//*[contains(@class, "information__deposit")]', document).iterateNext().innerText.replace('Залог', '').replace(' ', '').replace('₽' ,'').replace(' ', ''))
var comission = document.evaluate('//*[contains(@class, "information__commissionPercentage")]', document).iterateNext().innerText
var title = document.evaluate('//*[contains(@class, "information__title")]', document).iterateNext().innerText
if (comission == 'Без комиссии') {
comission = 0
}
var match = /(\d+)\/(\d+) эт./.exec(title)
var floor = match[1]
var totalFloors = match[2]
// console.log(link, address, price, comission, deposit, floor, totalFloors)
console.log([link, address, price, comission, deposit, floor, totalFloors].join(';'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment