def __extract_by_area(self, node, area_name): ''' 按照面积的大小分类 :param node: :param area_name: :return: ''' utils.print('提取按照面积分类的数据...') table = node.find('table') if table is None: utils.print('没有找到按照面积分类的数据') return [] row_node_list = table.find_all('tr') i = 0 house_list = [] for row in row_node_list: if i == 0: i += 1 continue columns = row.find_all('td') if len(columns) < 5: continue house = {} house['region'] = area_name house['area_level'] = columns[0].text house['deal_count'] = columns[1].text house['area'] = area = utils.get_num(columns[2].text) house['price'] = utils.get_num(columns[3].text) house['total_price'] = utils.get_num(columns[4].text) house_list.append(house) i += 1 return house_list
def __extact_by_type(self, node, area_name): ''' 提取了所有按照类型划分的数据 :param node: :return: ''' utils.print('提取按照户型分类的数据...') table = node.find('table') if table is None: utils.print('没有找到按照户型分类的数据') return [] row_node_list = table.find_all('tr') i = 0 house_list = [] for row in row_node_list: if i == 0: i += 1 continue columns = row.find_all('td') if len(columns) < 6: continue house = {} house['region'] = area_name house['house_type'] = columns[0].text house['deal_count'] = columns[1].text house['area'] = area = utils.get_num(columns[2].text) house['price'] = utils.get_num(columns[3].text) house['availableforsalecount'] = utils.get_num(columns[4].text) house['availableforsalearea'] = utils.get_num(columns[5].text) house_list.append(house) i += 1 return house_list
def __extract_by_use(self, node, area_name): utils.print('提取按照用途分类的数据...') table = node.find('table') if table is None: utils.print('没有找到按照用户分类的数据') return [] row_node_list = table.find_all('tr') i = 0 house_list = [] for row in row_node_list: if i == 0: i += 1 continue columns = row.find_all('td') if len(columns) < 3: continue house = {} house['region'] = area_name house['use_type'] = columns[0].text house['deal_count'] = utils.get_num(columns[1].text) house['area'] = area = utils.get_num(columns[2].text) house_list.append(house) i += 1 return house_list
def __extract_by_use(self, node, area_name): utils.print('提取按照用途分类的数据...') table = node.find('table') if table is None: utils.print('没有找到按照用户分类的数据') return [] row_node_list = table.find_all('tr') i = 0 house_list = [] for row in row_node_list: if i == 0: i += 1 continue columns = row.find_all('td') if len(columns) < 3: continue house = orm.OldHouseByUse() house.thedate = dt.now() house.region = area_name house.use_type = columns[0].text house.deal_count = utils.get_num(columns[1].text) house.area = area = utils.get_num(columns[2].text) house_list.append(house) i += 1 return house_list
def __extact_by_type(self, node, area_name): ''' 提取了所有按照类型划分的数据 :param node: :return: ''' utils.print('提取按照户型分类的数据...') table = node.find('table') if table is None: utils.print('没有找到按照户型分类的数据') return [] row_node_list = table.find_all('tr') i = 0 house_list = [] for row in row_node_list: if i == 0: i += 1 continue columns = row.find_all('td') if len(columns) < 6: continue house = orm.NewHouseByType() house.thedate = dt.now() house.region = area_name house.house_type = columns[0].text house.deal_count = columns[1].text house.area = area = utils.get_num(columns[2].text) house.price = utils.get_num(columns[3].text) house.availableforsalecount = utils.get_num(columns[4].text) house.availableforsalearea = utils.get_num(columns[5].text) house_list.append(house) i += 1 return house_list
def __extract_by_area(self, node, area_name): ''' 按照面积的大小分类 :param node: :param area_name: :return: ''' utils.print('提取按照面积分类的数据...') table = node.find('table') if table is None: utils.print('没有找到按照面积分类的数据') return [] row_node_list = table.find_all('tr') i = 0 house_list = [] for row in row_node_list: if i == 0: i += 1 continue columns = row.find_all('td') if len(columns) < 5: continue house = orm.NewHouseByArea() house.thedate = dt.now() house.region = area_name house.area_level = columns[0].text house.deal_count = columns[1].text house.area = area = utils.get_num(columns[2].text) house.price = utils.get_num(columns[3].text) house.total_price = utils.get_num(columns[4].text) house_list.append(house) i += 1 return house_list
def __decode_area(cls, column_nodes): house = {} if utils.remove_blank_char(column_nodes[0].text) == '建筑面积': house['build_area'] = utils.get_num(column_nodes[1].text) if utils.remove_blank_char(column_nodes[2].text) == '户内面积': house['inside_area'] = utils.get_num(column_nodes[3].text) if utils.remove_blank_char(column_nodes[4].text) == '分摊面积': house['share_area'] = utils.get_num(column_nodes[5].text) return house
def __decode_contact_num_row(self, column_nodes): project = {} if utils.remove_blank_char(column_nodes[0].text) == '合同文号': project['land_contact_num'] = utils.remove_blank_char(column_nodes[1].text) if utils.remove_blank_char(column_nodes[2].text) == '使用年限': yearstr = utils.remove_blank_char(column_nodes[3].text) project['land_years_limit'] = utils.get_num(yearstr) return project
def __decode_contact_and_price(cls, column_nodes): house = {} if utils.remove_blank_char(column_nodes[0].text) == '合同号': house['contact_code'] = utils.remove_blank_char( column_nodes[1].text) if utils.remove_blank_char(column_nodes[2].text) == '备案价格': price_text = utils.remove_blank_char(column_nodes[3].text) #58800元 / 平方米(按建筑面积计) house['price'] = utils.get_num(price_text) return house