# @R_419_5563@=utf-8"""Author: nIEliangcaiversion: 0.1date: 2019/7/29 11:30"""import requests_HTMLimport xlwtimport timeNow_time = time.strftime("%Y%m%d%H%M")session = requests_HTML.HTMLSession()House_List = ["海棠馨苑","馨浦苑","欣沁苑","欣乐苑","瑞和明庭","平安小区","景家堰","西林南路51号"]def write_house_data(table_info,title="地区房价%s.xls" %Now_time): file = xlwt.Workbook() for i in range(len(table_info)): address = table_info[i][0] Values = table_info[i][1] table = file.add_sheet(address) Title_List = [‘Title‘,‘house_info‘,‘height‘,‘total_price‘,‘unit_price‘] for i in range(5): table.write(0,i,Title_List[i]) # print(Values) for i in range(len(Values)): for j in range(len(Values[i])): # print(Values[i][j]) table.write(i+1,j,Values[i][j]) file.save(Title)all_house = []for house in House_List: URL = "https://sh.lianjia.com/ershoufang/rs%s/" %house res = session.get(URL) Title_all = res.HTML.find(".Title>a") #获取标题信息 house_info_all = res.HTML.find(".houseInfo") #房源信息 position_Info_all = res.HTML.find(".positionInfo") #位置 totalPrice = res.HTML.find(".totalPrice") #总价 unitPrice = res.HTML.find(".unitPrice") #单价 List_house = [] for i in range(len(Title_all)): List_house.append([Title_all[i].text,house_info_all[i].text,position_Info_all[i].text,totalPrice[i].text,unitPrice[i].text]) all_house.append(List_house)# print(House_List,all_house)zipped = List(zip(House_List,all_house))# print(zipped)write_house_data(zipped)总结
以上是内存溢出为你收集整理的买房指南,链接最近房源全部内容,希望文章能够帮你解决买房指南,链接最近房源所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)