身在国外的公司为什么下载不了公司的文件(附加爬虫代码)

有很多小伙伴不知道怎么才能运营好公司,于是就有身在国外的员工不知道怎么才能获得公司的具体信息,代码如下:

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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

名嘴小金

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值