-1

I try download this zip. I used selenium and requests, but neither of them works and I don't know why. Thank you for your advice.

from selenium import webdriver
import requests

url = 'http://vdp.cuzk.cz/vymenny_format/csv/20200131_OB_ADR_csv.zip'
driver = webdriver.Chrome('drivers\chromedriver.exe')
driver.get(url)

requests.get(url)
Žanet
  • 64
  • 1
  • 1
  • 7
  • Could you give us the stacktrace ? – Xhattam Feb 20 '20 at 14:22
  • 2
    `requests.get`, at least, doesn't write anything to the file system. It returns a `Response` object from which you can *read* the contents of the file; it's your responsibility to write that data to a file. – chepner Feb 20 '20 at 14:26
  • Does this answer your question? [Saving response from Requests to file](https://stackoverflow.com/questions/31126596/saving-response-from-requests-to-file) – Georgy Feb 20 '20 at 14:44

2 Answers2

2

requests.get() downloads the entity into memory. This needs to be explicitly written to a file using open.

Example:

import requests

url = 'http://vdp.cuzk.cz/vymenny_format/csv/20200131_OB_ADR_csv.zip'
filename = 'c:/users/user/downloads/csv.zip'

filebody = requests.get(url)
open(filename, 'wb').write(filebody.content)
Rohith N
  • 53
  • 4
0

First of all, you don't need requests to download a file (in this case at least). As I don't know the errors you are getting, I would suggest double-checking the path to your chromedriver.exe and you should escape backslashes.

driver = webdriver.Chrome('drivers\\chromedriver.exe')

I tried your code (while entering the location of chromedriver on my computer) and it worked - I was able to download the file.

Daniel Zaksevski
  • 68
  • 1
  • 2
  • 8