1

I am new to pyppeteer and try to download a csv. Unfortunately, without success. Suppose I want to download the following csv: 'https://people.sc.fsu.edu/~jburkardt/data/csv/addresses.csv'. Simply using

await self.page.goto('https://people.sc.fsu.edu/~jburkardt/data/csv/addresses.csv')

does not help. I tried to use

cdp = await self.page.target.createCDPSession()
await cdp.send('Page.setDownloadBehavior', { 'behavior': 'allow', 'downloadPath': '/test'})

but it's also not working. If someone knows how to make it work or can give me any advice, I'd highly appreciate that.

Patrick Balada
  • 1,330
  • 1
  • 18
  • 37

1 Answers1

0

You seem to miss the _client module of the page object. I am not that expert in python, but it seems that will do the job without createCDPSession(), also the path is suspicious that it is not recognized, try an absolute one as downloadPath.

await self.page._client.send('Page.setDownloadBehavior', { 'behavior': 'allow', 'downloadPath': 'C:/test' })
await self.page.goto('https://people.sc.fsu.edu/~jburkardt/data/csv/addresses.csv')
theDavidBarton
  • 7,643
  • 4
  • 24
  • 51
  • Thanks a lot for your response. Unfortunately, this doesn't seem to work. I don't get an error but it doesn't trigger a download either. – Patrick Balada Jun 17 '20 at 10:42
  • I see. **You might need an absolute path as `downloadPath`, perhaps the relative path is expected in different format and that causes a silent error.** I modify my answer like that. Other than that: does other part of your code works as expected? What if you leave out `self.` in general from your code? – theDavidBarton Jun 17 '20 at 11:50
  • Has changing the path solved the issue in the meantime? – theDavidBarton Jun 18 '20 at 14:09