Search code examples
pythonjsonserverdownloadurllib

Downloading JSON file through Python


I have a link that gives me a "save as" dialog box for a .pst file every time I run it. I want to try to save the file to a 'sample.txt' file without opening it since the size is 500 MB.

Is there any way to get around this..?

import urllib

jsonl = urllib.request.urlopen("test.com/csv?date=2019-07-17")

I have tried the code above but it gives me

<http.client.HTTPResponse at 0x9ac4k10>

Solution

  • Ok so I had a lot of trouble interacting with the site. I decided to just go with the webbrowser library.

    import webbrowser
    chrome_path="C:xxx\\Google\\Chrome\\Application\\chrome.exe"
    webbrowser.register('chrome', None,webbrowser.BackgroundBrowser(chrome_path))
    url = 'http://testsite/csv?date=2019-07-18'
    

    Setting chrome to download files automatically populates my download folder from where i can automate everything else :)