get_price.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # -*- coding: utf-8 -*-
  2. # @Author : ChenZhaoyuchen
  3. # @Time : 2024/9/27 16:17
  4. # @File : get_price.py
  5. from bs4 import BeautifulSoup
  6. from anjuke.utils.get_message import *
  7. from anjuke.utils.setting import *
  8. def get_price():
  9. price_list = []
  10. zhoubian_name_list = get_zhoubian_area()
  11. zhoubian_url_list = get_zhoubian_url()
  12. for i in range(len(zhoubian_name_list)):
  13. name = zhoubian_name_list[i]
  14. url = zhoubian_url_list[i]
  15. response_price = requests.get(url = url, headers = headers).content.decode('utf8')
  16. soup = BeautifulSoup(response_price, 'html.parser')
  17. price_ = soup.find(class_ = "table is-headless")
  18. table_trs = price_.find_all('div',class_ = "table-tr")
  19. for table_tr in table_trs:
  20. list = []
  21. yue_fang_lv = table_tr.find_all('div',class_ = 'td')
  22. for td in yue_fang_lv:
  23. a = td.text.strip()
  24. # Price_Rate = table_tr.find('div',class_ = "up") or table_tr.find('div',class_ = "down")
  25. # if Price_Rate.find('div',class_ = "up"):
  26. # tab = '上涨'
  27. # else:
  28. # tab = '下降'
  29. print(a)
  30. if __name__ == '__main__':
  31. get_price()