Use python requests to download CSV

前端 未结 8 1952
再見小時候
再見小時候 2020-11-29 18:34

Here is my code:

import csv
import requests
with requests.Session() as s:
    s.post(url, data=payload)
    download = s.get(\'url that directly download a          


        
8条回答
  •  一整个雨季
    2020-11-29 19:20

    I use this code (I use Python 3):

    import csv
    import io
    import requests
    
    url = "http://samplecsvs.s3.amazonaws.com/Sacramentorealestatetransactions.csv"
    r = requests.get(url)
    r.encoding = 'utf-8'  # useful if encoding is not sent (or not sent properly) by the server
    csvio = io.StringIO(r.text, newline="")
    data = []
    for row in csv.DictReader(csvio):
        data.append(row)
    

提交回复
热议问题