# -*- coding: utf-8 -*- # @Author : ChenZhaoyuchen # @Time : 2024/9/27 16:17 # @File : get_price.py from bs4 import BeautifulSoup from anjuke.utils.get_message import * from anjuke.utils.setting import * def get_price(): price_list = [] zhoubian_name_list = get_zhoubian_area() zhoubian_url_list = get_zhoubian_url() for i in range(len(zhoubian_name_list)): name = zhoubian_name_list[i] url = zhoubian_url_list[i] response_price = requests.get(url = url, headers = headers).content.decode('utf8') soup = BeautifulSoup(response_price, 'html.parser') price_ = soup.find(class_ = "table is-headless") table_trs = price_.find_all('div',class_ = "table-tr") for table_tr in table_trs: list = [] yue_fang_lv = table_tr.find_all('div',class_ = 'td') for td in yue_fang_lv: a = td.text.strip() # Price_Rate = table_tr.find('div',class_ = "up") or table_tr.find('div',class_ = "down") # if Price_Rate.find('div',class_ = "up"): # tab = '上涨' # else: # tab = '下降' print(a) if __name__ == '__main__': get_price()