1
我試圖通過python腳本從this page導出CSV。複雜的部分是在點擊this page上的導出按鈕後打開頁面,開始下載並再次關閉,而不僅僅是將文件託管在靜態的地方。我嘗試過使用請求庫,除此之外,它返回的文件是空的。Python - 從aspx網頁捕獲自動下載文件
這裏是我做了什麼:
url = 'http://aws.state.ak.us/ApocReports/CampaignDisclosure/CDExpenditures.aspx?exportAll=True&%3bexportFormat=CSV&%3bisExport=True%22+id%3d%22M_C_sCDTransactions_csfFilter_ExportDialog_hlAllCSV?exportAll=True&exportFormat=CSV&isExport=True'
with open('CD_Transactions_02-27-2017.CSV', "wb") as file:
# get request
response = get(url)
# write to file
file.write(response.content)
我敢肯定,我失去了一些東西很明顯,但我拉我的頭髮。
謝謝,丹尼。這是我害怕的答案。我會聯繫他們,看看會發生什麼。不幸的是,這看起來像是各州設立競選財務網站的常見方式。 –