Python 下载网络文件

# -*- coding: utf-8 -*-
import requests
import csv
#下载文件
def downloadfiles(url,count):
	f = requests.get(url)
	filename = str(count)+".pdf"
	with open(filename,"wb") as code:
		code.write(f.content)
#从csv读取内容
def readfile(path):
	with open(path,'r',encoding='utf-8') as csvfile:
		read = csv.reader(csvfile)
		i=0
		for one in read:
			downloadfiles(one[0],i)
			i = i+1
			print(one[0])
readfile("d:\\baoxian_pdf.csv")

 

你可能感兴趣的:(python)