![](/img/trans.png)
[英]Why can't I play the MIDI files I have downloaded programmatically, but I can play them when I download them manually?
[英]Why is that I can visit https webpage containing public files but I can't download them using Python script?
我的用戶名和密碼應該是什么?
import requests
import shutil
url = "https://www.sec.gov/Archives/edgar/daily-index/2017/QTR1/company.20170111.idx.txt"
#Note: It's https
r = requests.get(url, auth=('', ''), verify=False,stream=True)
r.raw.decode_content = True
with open("company.20170111.idx.txt", 'wb') as f:
shutil.copyfileobj(r.raw, f)
您要加載的網址應為:
https://www.sec.gov/Archives/edgar/daily-index/2017/QTR1/company.20170103.idx
您還缺少import requests
,並且服務器端不喜歡auth
參數。
import shutil
import requests
url = "https://www.sec.gov/Archives/edgar/daily-index/2017/QTR1/company.20170111.idx"
r = requests.get(url, verify=False, stream=True)
r.raw.decode_content = True
with open("company.20170111.idx.txt", 'wb') as f:
shutil.copyfileobj(r.raw, f)
這很好。 我不知道為什么:
import urllib2
url = "https://www.sec.gov/Archives/edgar/daily-index/2017/QTR1/company.20170111.idx"
r = urllib2.urlopen(url)
for l in r:
print l
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.