def __parse_base(self, item, city_name, point_type): point = Point() point.prov = self.uid point.type = point_type point.phones = [normalize_phone(item('.content_table table tbody tr:eq(0) td:eq(0) .office_phone').remove().text())] name_address_html = replace_br(item('.content_table table tbody tr:eq(0) td:eq(0)').remove().html(), ',') name, address = PQ(name_address_html).text().split(',', 1) point.name = normalize_text(name) point.address, point.place = self.__get_address(city_name, address) point.check_information = CHECK_OFFICIAL script_text = item('.ya_map script:eq(1)').text() for line in map(strip, script_text.splitlines()): if line.startswith('BX_GMapAddPlacemark('): lat_token = "'LAT':'" lat_start_index = line.find(lat_token) + len(lat_token) lat_end_index = line.find("'", lat_start_index) point.lat = line[lat_start_index:lat_end_index] lng_token = "'LON':'" lng_start_index = line.find(lng_token) + len(lng_token) lng_end_index = line.find("'", lng_start_index) point.lng = line[lng_start_index:lng_end_index] point.check_coordinates = CHECK_OFFICIAL break else: warning_not_official_coordinates(point) return point
def __parse_base_office_exchange(self, item, point_type): point = Point() point.prov = self.uid point.type = point_type point.name = normalize_text(item('h2').text()) point.address = normalize_address(item('.itemFilialIn>p:eq(0)').text()[len(u'Почтовый адрес:') + 1:]) is_phone = False phones_items = self.__phone_splitter.split(item('.itemFilialIn>p:eq(1)').text() or '') for sub_item in phones_items: sub_item = normalize_text(sub_item).lower() if sub_item == u'телефон': is_phone = True continue if sub_item == u'факс': is_phone = False continue if is_phone: point.phones.append(normalize_phone(sub_item)) point.time = normalize_time(', '.join(map(lambda sub_item: PQ(sub_item).text(), item('.workTime p')))) point.check_information = CHECK_OFFICIAL warning_not_official_coordinates(point) return point
def __parse_base_offices_exchanges(self, item, point_type, keywords_names): point = Point() point.prov = self.uid point.type = point_type point.name = normalize_text(item('.first').text()) if not point.name.startswith(keywords_names): return None city = item('.field-field-city').text() if city: city = u'г. ' + city else: city = item('.field-field-index').text() address = item('.field-field-adress').text() point.address, point.place = split_address_place(u'%s, %s' % (city, address)) phone = item('.field-field-phone').text() if phone: point.phones = [normalize_phone(phone[len(u'тел.:')])] point.time = normalize_time(item('.field-field-work-time .field-item').text()) point.check_information = CHECK_OFFICIAL warning_not_official_coordinates(point) return point