If I have an iframe loading a website from a different server, like bing.com, can I manipulate or retrieve the code from that iframe?
If not, I can do a curl request and create the iframe from that and then manipulate it, right?
In javascript you can't access the contents of an iframe if that site resides on a different domain than the one you are loading the iframe from. You can proxy the page load by having a PHP scrip that "curls" the request. There is a lot more involved than that though to cleanly proxy another site.
Related
I am building a scraper to scrape content using guzzle and symfony dom crawler But I run into an issue.
The page I am scraping has multiple Iframe servers They default iframe is shown when the scraper loads the page but in order to get the other servers it needs to click there buttons and so it reflects the server iframe.
How do I do that?
Guzzle can't render Javascript websites so it doesn't support that
There are two ways around this either check for network tabs and send the request to the ajax link they get the iframes from, or use symfony Panther as headless browser library they support javascript websites and even Bypass Cloudflare Protection
I need to simulate from within an iframe in our site, which uses https and it's loaded only once upon the authentication on our site, the authentication into another site, which only uses http.
How can I do that?
We first tried loading into the iframe a page of our site from which the login form for the remote authentication is automatically submitted with javascript. This cannot be achieved because the http request from the form is blocked by the browser for security reasons. I must clarify that if we use http in our web too, the authentication is done without problems.
I'm not sure if using file_get_contents() will do the trick, because it's not a simple static page what we need to display. We need to keep any data from the remote login (cookies, etc) in the browser so that we can access other parts of the remote web (once I've signed in) from other places of our site. As far as I know, file_get_contents doen't provide any header.
Another alternative I've also considered is curl, using CURLOPT_RETURNTRANSFER=true and CURLOPT_HEADER=true and trying to manually set any cookies I get in the header. I'm not sure if keeping the session implies more actions though.
How to display other sites content in our site and server without using iframe?
In fact, I'm going download a page (same domain) and display in my server via php like browsers.
Note: file_get_contents works well, but "CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource" so all stylesheets and some images are not loaded.
Is there a way to do it?
I think in PHP you can't do this, because some website header block access for you. I would do this in js/jquery like this:
Ajax/jQuery - Load webpage content into a div on page load?
I am using PHP Scriptable Web Browser for downloading some data from
one web site and that website contains so many links https://www.xxxx.com/CWRWeb/ReportNav.do?rid=CHARGEBACK using this link i want to download the data this page contains one iframe when is access this page using my script i am able to get the that page contain but not able to get iframe content from that page
can any one guide me.
Thank you.
i need to fetch a url with javascript/jquery and not php.
i've read that you could do that if you got a php proxy, but that means that it is still going through php. cause then it's still the ip of the server that is fetching it.
could one fetch the url entirely with only front-end, and thus fetch it with the client's ip?
There exists a Same origin policy for AJAX requests. This prevents Javascript on, say, this site, from making a request to gmail.com (with your cookies), reading your e-mails, and uploading them to the StackOverflow server. Javascript on stackoverflow.com can only make AJAX requests to pages on that domain.
As you can see, this is essential for security. Requests must instead be made by a proxy running on your web server - PHP can be used, but there are other solutions. For example, Ajax Cross Domain is an AJAX library that communicates with a Perl script running on the server to emulate AJAX requests for other domains.
It is also possible to make requests on other domains via a javascript include (script tag), image tag, etc. but in these cases you cannot read the contents of the page.
You cannot do this with an iframe either: scripts cannot see the internals of iframes unless they are on the same domain as the script.
So in short, use a proxy.
The problem is that jQuery would fetch an url with AJAX and AJAX won't operate cross-domain because of the potential security (as per the same-origin policy).
There are however ways to emulate this, if you load the page in an iframe you can retrieve the data by using innerHTML on the iframe. Here's an example script that uses jQuery: http://code.google.com/p/jquery-crossframe/