Commit fde8c83d by 岳巧源

add new script

parent be90278e
import logging
import time
import zipfile
import push
import requests
url = "http://pfd.premierfarnell.com/eCat_element14_CN_BI.zip"
file_name = "eCat_element14_CN_BI.zip"
unzip_name = "eCat_element14_CN_BI.txt"
# 解压缩的文件保存目录
save_path = "/data/golang/src/europa-erp-go/scripts/"
logger = logging.getLogger("element_14_data_process.py")
def download_zip_file(url=""):
start =
start = time.time()
response = requests.get(url=url)
with open(file_name, 'wb') as f:
f.write(response.content)
end = time.time()
logger.info("文件 %s 下载完成,用时:%s" % (file_name, str(end - start)))
def unzip_file(file=""):
f = zipfile.ZipFile(file)
logger.info("开始解压文件 %s " % file)
f.extractall(save_path)
logger.info("文件 %s 解压完成" % file)
if __name__ == '__main__':
unzip_file(file_name)
......@@ -43,7 +43,7 @@ ladder_map = {
}
producer = push.Producer()
producer.get_connn()
......@@ -142,6 +142,7 @@ if __name__ == '__main__':
download_file(url)
time.sleep(1)
# 处理并推送json字符串数组
producer.get_connn()
HandleCSV().parse(file_name)
time.sleep(1)
producer.close()
......
......@@ -25,7 +25,7 @@ ladder_map = {
file_name = "Tianyang_InventoryFeed.csv"
url = "https://www.waldomapac.com/dailyFeed/Tianyang_InventoryFeed.csv"
producer = push.Producer()
producer.get_connn()
def download_file(url=""):
......@@ -129,6 +129,7 @@ if __name__ == '__main__':
download_file(url)
time.sleep(1)
# 处理并推送文件
producer.get_connn()
HandleCSV().parse(file_name)
time.sleep(1)
producer.close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment