由于在Python(2.7),我真的是一个新手在寻找下一个建议:由Python的链接下载文件存储在CSV
我有分隔的一列逗号存储HTTP链接csv文件。
http://example.com/file.pdf,
http://example.com/file.xls,
http://example.com/file.xlsx,
http://example.com/file.doc,
主要目的是循环所有这些链接并通过它们下载文件的原始扩展名和名称。
所以我的搜索结果,并帮助这里给我下一个脚本:
import urllib2
import pandas as pd
links = pd.read_csv('links.csv', sep=',', header =(0))
url = links # I know this part wrong by don`n know how to do right
user_agent = 'Mozilla 5.0 (Windows 7; Win64; x64)'
file_name = "tessst" # here the files name by how to get their original names
u = urllib2.Request(url, headers = {'User-Agent' : user_agent})
req = urllib2.urlopen(u)
f = open(file_name, 'wb')
f.write(req.read())
f.close()
请任何帮助
P不是肯定大熊猫 - 也许CSV更好?
那么http://stackoverflow.com/a/19602990/3014866? –