update
This commit is contained in:
@@ -73,7 +73,9 @@ def scrape():
|
||||
# 解析 JSON 数据
|
||||
json_data = response.json()
|
||||
# 遍历数据并下载文件
|
||||
for row in json_data['ROWS']:
|
||||
print("total:" + str(json_data['RECORDS']))
|
||||
for index, row in enumerate(json_data['ROWS']):
|
||||
print("index:"+str(index))
|
||||
part_number = row[0] # 部件编号
|
||||
file_links_str = row[4] # 文件链接
|
||||
|
||||
@@ -209,7 +211,7 @@ def scrape():
|
||||
file_response = requests.get(file_url)
|
||||
file_response.raise_for_status()
|
||||
|
||||
# 保存文件
|
||||
# 保存文件1685+431+314
|
||||
file_path = os.path.join(folder_path, os.path.basename(file_url))
|
||||
with open(file_path, 'wb') as file:
|
||||
file.write(file_response.content)
|
||||
@@ -226,15 +228,19 @@ def scrape():
|
||||
device_batch=None
|
||||
manufacturer=row[2]
|
||||
experiment_date=row[3]
|
||||
data_db = [get_md5(row[0]), 'Crawler', datetime.now(), None, None, None,
|
||||
origin_data = ','.join(row)
|
||||
|
||||
data_db = [get_md5(''.join([device_name,device_function,manufacturer])), 'Crawler', datetime.now(), None, None, None,
|
||||
device_type,
|
||||
device_name, device_mode,
|
||||
device_function,
|
||||
device_batch, manufacturer,
|
||||
experiment_date,
|
||||
'NASA', None, None, ','.join(upload_ids)
|
||||
'NASA', None, None, str(upload_ids),origin_data
|
||||
]
|
||||
save_to_db_import_record(nasa1_connection, data_db)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
finally:
|
||||
# 关闭游标和连接
|
||||
nasa1_connection.close()
|
||||
|
||||
Reference in New Issue
Block a user