C2M Scrape add

This commit is contained in:
Yam ZhengLim
2024-01-27 14:46:57 +08:00
parent e53a9817a6
commit 4ff602f2c6
9 changed files with 280 additions and 36 deletions
+21
View File
@@ -0,0 +1,21 @@
from google.cloud import storage
def login_cloudstorage_credential(credential):
try:
storage_client = storage.Client.from_service_account_json(credential)
return storage_client
except Exception as e:
print(e)
print("[FUNCTION_ERROR]-login_cloudstorage_credential")
return False
def upload_to_bucket(storage_client, blob_name, file_path):
try:
crisp_bucket = storage_client.get_bucket('exchange_competitor_bucket_raw')
blob = crisp_bucket.blob(blob_name)
blob.upload_from_filename(file_path)
return print("[Upload Complete]",file_path)
except Exception as e:
print(e)
print("[FUNCTION_ERROR]-upload_to_bucket",blob_name)
return False