#!/usr/bin/python3
import requests,openpyxl,time,shutil,sys
try:
Search_Addres = sys.argv[1]
information = shutil.copy(r'./xxxx.xlsx', r'./'+ str(time.strftime('%Y-%m-%d',time.localtime(time.time())))+'.xlsx')
open_excel=openpyxl.load_workbook(filename = information)
rw_sheet=open_excel["sheet1"]
except Exception as e:
print ('使用方法: python xxxx.py \"输入的内容\"')
sys.exit()
response = requests.get(
'https://xxxx.xxxx.com/items?+str(Search_Addres),
headers={'host': 'xxxx.xxxx.com','Accept': 'application/json'},timeout=100).json()
keys = ["a","b","c","d","e","f","g","h","i","j","k","l","m"]
for item in range(len(response)):
excel_column = 0
excel_raw = (rw_sheet.max_row)+1
print ("正在写入第:"+str(int(excel_raw-1)))
for key_value in keys:
try:
key_value = response[item][key_value]
except:
key_value = 'Null'
excel_column += 1
rw_sheet.cell(row=excel_raw, column=excel_column).value=(key_value)
open_excel.save(information)
open_excel.close()