How to load entire website (external link) with functionality on my webpage? - javascript

I want to integrate this external example link on my web page. I am using PHP scripting language.
I have used file_get_contents, wget and all things but its only get HTML content.
I want to load entire site on my webpage. I don't want to use Iframe and tags because of security purpose I cant share URL with Users.
So please give me advice on this.
Is this we can do like how the proxy site works? Please help me on this.
Thanks in advance. :)

Related

Loading the html of a different website

I'm looking to get some data from a Facebook page of a restaurant, but I'm kinda stuck. I want to load some divs from the facebook page of the restaurant, then get the ID's of the divs, since they contain some information i would like to use. Ive tried using the .load function from jQuery, but no luck. Of all the answers I've seen, they all include a url that's something like somefile.html. Is it possible to load the divs ids and some innerHTML from a live page like Facebook? Are they somehow downloading the html to a file then using that? Keep in mind I know nothing about PHP, so any solutions? Thanks!
The right way to do it would be though Facebooks graph API, take a look at this site and see if it offers the information you need https://developers.facebook.com/docs/graph-api/reference/page/
NOTE
As comments have pointed out, "web scraping" is FORBIDDEN on Facebook.com by Facebook policy. http://www.facebook.com/apps/site_scraping_tos_terms.php
Technically, I don't think this is possible with Facebook and just JavaScript.
In general, using just JavaScript, one solution would be to load the (external) site like FaceBook into an Iframe, and then grab all the DIVs and search the DOM that's loaded into the iFrame. However, I believe FaceBook (and other sites) set something called "CORS Request Headers" which prevent the page from loading into an iFrame -- also, as far as I know, this cannot be hacked around except to use another language to pull the HTML as a file (like with PHP).
Sources:
Facebook Forbids iFrames
JavaScript, Load Page in iFrame

I want to create a widget which will render an application on sites who add that Widget to their webpage

I want to create a widget or a javascript code which will render a HTML form on the webpage where the code is embedded.
eg. www.example.com wants to show a BMI calculator which is hosted on www.example2.com example2 wants to share that BMI with example.com but is not giving the actual code. He will share just a js code ( Like how we include Google Analytics or Google Ads ). Whats the best way to achieve this?
In this calculator we are asking multiple details from the user which are saved in database on www.example2.com in db .
I don't want to go Java Applet or Flash way. Currently I have to share HTML code of the BMI calculator which is not ideal.
What are the possibilities here.
Thanks
There are two ways to do this: the iframe and javascript.
The more common way is to use the iframe, as it is a simple webpage on which you have full control. More, the best advantage is that the iframe is loaded asynchronously so the loading of the page isn't affected by the loading of the widget.
This is the approach that Facebook uses and as it does, also all other major sites use the same approach.
As pointed out in comments, using iframes permits you to use also the cookies, load css, javascript, ecc as it is a full webpage.
to use iframes you have to use a code like this:
<iframe id="WidgetContent" src="http://example.com/widget/id" frameborder="0" height="600"></iframe>
It's very simple!

Show external website in my aspx page and include own javascript

What I am trying to accomplish:
A visitor of my website should be able to load an external website into my website and click elements on this external websites to retrieve the XPath of the element. Like Firebug but completly online.
I have already managed to create a piece of javascript to click elements on MY website and return the XPath of the element.
Now I need to know how to show an external website in my ASP.NET WebForms page and inject my own javascript.
I tried to use a literal control and download the external website's HTML code with a WebClient.
WebClient webClient = new WebClient();
string result = webClient.DownloadString(txtURL.Text);
litWebsite.Text = result;
Problem here is: The the external website's design will be broken if I don't consider the CSS references.
Maybe this is a complete wrong approach.
Any ideas?
Thank you!
I'm not sure it's possible.
Sure, you could display the web page via iframe but unless you owned the content, I'm not sure you can control it with your own javascript.
Maybe I'm wrong but I've always heard that your could do very little with other web content in your own project.

Clone Facebook wall posting via jQuery?

I would like to mimic Facebook's functionality where when you attach a link, it will read the meta data and image automatically:
Anyone know how to accomplish this interface functionality with jQuery?
It's not reading meta data of the image, it's reading actual data from the page. It does this, probably, with cURL:
http://php.net/manual/en/book.curl.php
tutorial:
http://phpsense.com/php/php-curl-functions.html
You can't do cross domain scripting with JavaScript so you will have to use a server side language such as PHP and then have PHP crawl the page and find the main content area of the description of the page... Hope that helps :\ it's not really a front end type of thing.

Can I host a file or folder on another person's domain?

I don't think this is possible, but it never hurts to ask.
Is there any way for me to host a file (or folder) on someone else's domain (with their permission, of course)? For example, if their site is hosted at www.example.com, I would like to host a file at www.example.com/foo.html, or a folder at www.example.com/foo/, or the like. I just need to be able to make changes at will to a single file.
We can't use a redirect or anything like that - the purpose of this is to allow me to control a document loaded in an <iframe> on their site, and for the JavaScript in that <iframe> to have access (i.e., no security restrictions) to its parent page - which is only allowed if the domains match. Their site doesn't change the document.domain property to relax the security restrictions, nor can we ask them to start using that approach (it's an enormous site).
I also can't generate an <iframe> and create its document solely using JavaScript - we've done that in the past, and it gets around the security restrictions (the generated <iframe> is in the same domain as its parent page), but it causes other issues and difficulties that add up to a deal-breaker in this case.
Please let me know if you have any alternative suggestions, or if you need any more information about what exactly I'm trying to do.
Thanks in advance for any help!
I hope I'm understanding this correctly. Since you have their permission to host a file on their site, can you just use FTP? They can set you up to only be able to drop files in one directory on their site, and you can edit the file there.
Provide embed code to the other party to load remote javascript file to their page. You may then generate content or information gathering. As the javascript file is hosted on your side, it's under your control. A Visitor Counter is a similar case.
You could make a php script that loads it's data from your own site.
this should work actually:
<?php echo file_get_contents("http://www.yoursite.com/yourfile.html"); ?>
Edit: You might be able to do the same with javascript, but i don't know the code for it... Sorry. :-/
Sounds like your friend can set up a reverse proxy rule on their web server for your file. http://httpd.apache.org/docs/2.0/mod/mod_proxy.html

Categories

Resources