Created
April 6, 2021 09:17
-
-
Save rtrv/19f21c7932db2ca00ab12aa6a04e6e29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'open-uri' | |
require 'pry' | |
require 'active_support/all' # TODO: limit requirement | |
class SpbRealEstatePropertiesParser | |
BASE_URL = 'https://dominfospb.ru' | |
def call | |
# Найти список адресов | |
list = ['Крапивный 3'] | |
# Разбить список на отдельные дома | |
# Для каждого дома сделать поиск, убедиться, что там найден один дом | |
list.each do |address| | |
url = build_search_url(address) | |
binding.pry | |
html = Nokogiri::HTML.parse(open(url)) | |
estate_id = search_estate_id(html) | |
# дёргаем URL, смотрим количество найденных домов | |
# Проваливаемся с неудачным поиском в отдельный лог, делаем запись с обнаруженной проблемой | |
# С удачным поиском идём на нужную страницу и закидываем оттуда все в CSV | |
end | |
binding.pry | |
end | |
private | |
def scrape_estate_list | |
end | |
def search_estate_id | |
end | |
def scrape_estate_properties | |
end | |
def build_search_url(estate_address) | |
search_params = { adres: estate_address } | |
[BASE_URL, search_params.to_param('search')].join('/') | |
end | |
end | |
SpbRealEstatePropertiesParser.new.call |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment