0

I have a Python app navigating through a website using Webbot. On the final page, it renders and streams a PDF to the browser (without an endpoint URL). This is displayed in the chrome PDF viewer but I need to download this.

I am unsure of how to go about activating the download here or obtaining this file through the normal method of request.get()

The URL is generic: www.website.com/generatePDF

chrome viewer showing download button

I can navigate to this page, I'm just not sure how to go about getting the actual PDF downloaded. Because everything uses scripting on the backend, I need to navigate button clicks (URL's are hidden).

Thoughts?

  • What exactly are you expecting? explain that clearly, also post the URL and the whole code you've tried. – AbiSaran Dec 28 '22 at 05:42
  • I thought stating what I was trying to do in detail with screen shots was pretty clear about what I was expecting? The URL doesn't matter at all, but here: https://idocmarket.com/ABCDE/Document/PrintDocumentWithRotations The question is, how do you target a button with webbot in a plugin (the chrome PDF viewer), such as the screenshot shown. I haven't tried code to target it, because I can't find code in webbot API's that allows it. – Jason Orman Dec 29 '22 at 18:01
  • 1
    You are not asking a logical question or logical idea to create a program or application. You are asking about how to do a particular action, which means using Selenium and Python how to click the button, right? For this I can answer generally like this - you have to find that WebElement then you have to implement the click() action on it, that's it. Is this enough for you? If you post the proper URL, we can debug and suggest some solution for that, if you dont want that, go ahead, and best of luck. Also, the URLs you posted are not working, Page Not Found appears. – AbiSaran Dec 30 '22 at 02:53
  • I'm not sure what part of "I posted the URL" and "there are no elements because it's in a chrome PDF reader plugin" isn't making sense? I posted the URL. I posted there are no elements. I posted that it's in a chrome PDF viewer. I'm not sure how much more clear I can be on this. I even posted a screen shot of it. – Jason Orman Jan 04 '23 at 00:49

1 Answers1

0

Have you consider sending CTRL+S command? It should send the save command and then click on SAVE button. Never tried but could do the job.

rpi
  • 1
  • This is an interesting idea, I will have to see if webbot has that functionality. If so, that might work? – Jason Orman Jan 03 '23 at 20:24
  • I have tried this now using: driver.press(driver.Key.CONTROL + 's') but no luck. While I can press this key combination in the web browser, it doesn't actually seem to work. – Jason Orman Jan 04 '23 at 00:40
  • To clarify, it doesn't seem to work in the spawned web browser programmatically. If I do it by hand in the same window it does work. – Jason Orman Jan 04 '23 at 00:47
  • Yes, exactly `driver.press(driver.Key.CONTROL + 's')`. I tried this option and it seems not working... Finally I solved getting the url of the pdf with `driver.get_current_url()` and downloaded with `requests.get(pdf_url)` and wrote a pdf file. Another option could be using `wget` after you have the target page url. Unfortunaltely I noticed that `driver.get_current_url()` sometimes fails if I create a driver without GUI. Hope it helps you...! – rpi Jan 04 '23 at 12:34
  • I'm running into the problem that the url is masked: idocmarket.com/ABCDE/Document/PrintDocumentWithRotations if you go to that url the PDF doesn't actually exist there, it's just a streamed document to the browser. Not sure if I'm going to be able to grab the file ultimately. – Jason Orman Jan 05 '23 at 23:40