How to Grab Components From Any Web Page
Briefly

Extracting the source of elements from a webpage can be challenging, particularly because many modern websites implement strict Content Security Policies (CSP) and same-origin policies that limit how their content can be displayed or manipulated in iframes. While theoretically, you could use JavaScript to capture click events and prevent default behaviors, these security measures may render your approach ineffective. Furthermore, executing scripts within an iframe from a different origin can lead to complications, making this solution less practical for sites that have explicitly forbidden being loaded in iframes.
You can technically grab an element's source code by opening a webpage in an iframe and attaching a click event to it, but many pages enforce their own Content Security Policies, which often block this. When a site blocks itself from being framed for security reasons, trying to extract data through JavaScript can be thwarted by same-origin policy restrictions.
Preventing the default functionality of the click event while running your own script is somewhat feasible in an iframe scenario. However, if the webpage you are trying to load is set to prevent framing, you will either simply see a blank iframe or receive an error message.
Read at SitePoint Forums | Web Development & Design Community
[
|
]