0

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>
3
  • Well... that's the response from server Commented Jul 18, 2019 at 20:38
  • Could you help me understand how I can interact with it? Im not sure where to start.. Commented Jul 18, 2019 at 20:39
  • Check this from the docs Commented Jul 18, 2019 at 20:42

2 Answers 2

1

You need to read the data out of the object that urlopen returns.

Try

import urllib
with urllib.request.urlopen("test.com/csv?date=2019-07-17") as f:
        jsonl = f.read()
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the response, but nothing happened. It just took a minute to run but no output.
1

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 :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.