python3 使用urllib3通过代理下载网易财经报告

天池大赛A股财报数据 百度链接: https://pan.baidu.com/s/1zUaA4Q_sHs2lsI3Nb1_v0g 密码: c5xv

本文的完整可下载所有A股财报的程序可访问https://github.com/dreamnotover/stock_financial/

# -*- coding: utf-8 -*-
"""
Created on Thu May 17 14:43:27 2018


@author: wenhua
"""
import os
import urllib3
import random
from urllib3.exceptions import NewConnectionError, ConnectTimeoutError, MaxRetryError,HTTPError,RequestError,ReadTimeoutError,ResponseError


   
try:
    with open('user-agents.txt') as f:
       lines = f.read().splitlines()
    agent=random.choice(lines)
    proxy = urllib3.ProxyManager('http://182.106.140.122:80/',headers={'user-agent': 'Mozilla/5.0 (Darwin; FreeBSD 5.6; en-GB; rv:1.9.1b3pre)Gecko/20081211 K-Meleon/1.5.2'})
    r=proxy.request('GET',  'http://quotes.money.163.com/service/zycwzb_002243.html?part=yynl', preload_cont

你可能感兴趣的:(python,量化金融)