Shermaine Yeo
Shermaine Yeo

Reputation: 1

Python Selenium: How to access iframe source without src attribute?

There is a webpage where I would like to access the iframe source to download a file.

The problem is, there is no src attribute in the iframe or its html, it’s inside #document. How to I get the link from inside #document?

example:

<iframe title=“PDF Preview”>
    #document (url is here)
    <!DOCTYPE html>
    <html>
        <head></head>
        <body>
            <embed src=“about:blank”>
        </body>
    </html>
</iframe>

I can switch to the iframe but I can only retrieve attributes within the tags html, head etc. but I’m not able to get the link inside #document. Is there a way to retrieve/go to the url inside #document?

Actual html: actual html

Upvotes: 0

Views: 35

Answers (1)

K J
K J

Reputation: 11857

When documents are served in this fashion for security reasons there is no direct access. The server usually responds with a HTML message that via "Digital Transformation" converts into a local binary.pdf.

Similar questions will usually say it is a URL behind SalesForce "Shields" "I can’t share the link of the website as it is confidential. It’s salesforce website." and there the answer should stop. However by way of explanation!

The inspector simply offers the carrier not the content as a file (although it HAS already been downloaded to the Browsers cache thus is local). You can manually or programmatically emulate the "save as" output function.

enter image description here

There is no longer a "networked" document of 1,402 KB as we can see in other views, just the HTML carrier. The LOCAL URL is the cached embedment as shown in the internalid=.

enter image description here

If you have "public access" to that server reference you can simply command line URL (cURL) the file in one line. But if the access is via API "login" that will not be "trivial", since needing authorisation first.

enter image description here

Your next question may be. Where is the PDF held in limbo? That varies from browser to browser and user applications. So for this browser it is in a folder with a servlet name, but that is not usual as simply older legacy Internet Explorer.

enter image description here

Upvotes: 0

Related Questions