有很多小伙伴不知道怎么才能运营好公司,于是就有身在国外的员工不知道怎么才能获得公司的具体信息,代码如下:
import pandas as pd
import os
import requests
def download_file(company_name,local_folder):
download_url = f"https://zhengxin-pub.bj.bcebos.com//excel/【爱企查】{company_name}工商注册信息.xls"
local_filename = f"{company_name}.xls"
local_file_path = os.path.join(local_folder, local_filename)
os.makedirs(local_folder, exist_ok=True)
response = requests.get(download_url)
if response.status_code == 200:
with open(local_file_path, 'wb') as file:
file.write(response.content)
print(f"{local_filename}已下载并保存到: {local_file_path}")
else:
print(f"{company_name}公司文件下载失败,状态码: {response.status_code}")
def get_company_list(file_name):
df = pd.read_excel(file_name)
company_list = df['公司名称'].tolist()
return company_list
if __name__ == '__main__':
file_name = 'test1.xls'
local_folder = "Downloads"
company_list = get_company_list(file_name)
print(f"共获取到{len(company_list)}个公司信息")
for company_name in company_list:
print(f"正在下载{company_name}公司文件,还剩{len(company_list)-1}个")
download_file(company_name, local_folder)