for jf in tracks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | for jf in tracks: with open(jf+".tmp") as data_file: data = json.load(data_file) data_file.close() barcode = data["list"][0]["trackingItem"]["barcode"] title = data["list"][0]["trackingItem"]["title"] origCN = data["list"][0]["trackingItem"]["originCountryName"] print jf trHist = data["list"][0]["trackingItem"]["trackingHistoryItemList"] with open(index,'a') as index_file: #and unicode! index_file.write(barcode.encode("utf-8", "ignore")+" "+title.encode("utf-8", "ignore")+"<br/> \n") if str(trHist) != "None": ihistlen = len(trHist) for k in range(0,ihistlen-1): index_file.write(data["list"][0]["trackingItem"]["trackingHistoryItemList"][k]["date"]+" ") index_file.write(data["list"][0]["trackingItem"]["trackingHistoryItemList"][k]["humanStatus"]+" ") #unicode again! description = data["list"][0]["trackingItem"]["trackingHistoryItemList"][k]["description"] index_file.write(description.encode("utf-8", "ignore")+" <br/> \n") index_file.write("<br/> \n <br/> \n <br/> \n") index_file.close() |
Результат в точности повторяет предыдущий. На выходе скучнейший index.html с минимальной разметкой.
Комментариев нет:
Отправить комментарий