doron447 Posted August 31, 2013 Share Posted August 31, 2013 Hi,I'm trying to find a way to which I could pull content and style from array of website's.In simple words, I want to use commands such as:document.getElementById("somename")on specific url and not on my webpage.Can I do that?Incase not, what method should I use?Thank you,Doron Quote Link to comment https://forums.phpfreaks.com/topic/281729-pull-html-content-and-style-from-other-website/ Share on other sites More sharing options...
Irate Posted September 1, 2013 Share Posted September 1, 2013 It is frowned upon to steal from other sites... But, anyway, your best guess is PHP - $othersite = file_get_contents("http://someurl.com"); would copy the contents of the source code into the variable $othersite. If you cannot use PHP, use document.documentElement.innerHTML.toString() in JavaScript, that'd give you the entire head and body content of the site, though you'd might need to check for any attributes on the documentElement if they are relevant to the site flow (like, if its dir attribute it rtl and not ltr, or the lang is something other than en). Once again, stealing stuff from other sites is frowned upon. Don't do it. Examples above are just for documentation purpose, I do not condone any misconduct... Quote Link to comment https://forums.phpfreaks.com/topic/281729-pull-html-content-and-style-from-other-website/#findComment-1447715 Share on other sites More sharing options...
.josh Posted September 2, 2013 Share Posted September 2, 2013 you cannot use javascript to get contents from a page hosted on another domain, unless the target domain is specifically setup to allow cross domain scripting. Quote Link to comment https://forums.phpfreaks.com/topic/281729-pull-html-content-and-style-from-other-website/#findComment-1447753 Share on other sites More sharing options...
Irate Posted September 2, 2013 Share Posted September 2, 2013 Technically he could run scripts on his console while visiting the site, which is what I explained in my second-to-last paragraph. Quote Link to comment https://forums.phpfreaks.com/topic/281729-pull-html-content-and-style-from-other-website/#findComment-1447768 Share on other sites More sharing options...
.josh Posted September 2, 2013 Share Posted September 2, 2013 why would you even mention for him to go to the site and do it in the console? The whole point of coding is to automate something so that you don't have to manually do it yourself. Quote Link to comment https://forums.phpfreaks.com/topic/281729-pull-html-content-and-style-from-other-website/#findComment-1447817 Share on other sites More sharing options...
Irate Posted September 2, 2013 Share Posted September 2, 2013 He's even mentioning using Client-Side mechanics on another website, so the console is what came to my mind I do not think that it's useful, but it's still a possibility. Quote Link to comment https://forums.phpfreaks.com/topic/281729-pull-html-content-and-style-from-other-website/#findComment-1447818 Share on other sites More sharing options...
kicken Posted September 2, 2013 Share Posted September 2, 2013 If he wanted to do it manually, he could just go to the site and use file->save as, no need to fiddle around in the js console trying to extract the html. For what he wants, he will need to use something like PHP to download the URL content and then extract the data. Quote Link to comment https://forums.phpfreaks.com/topic/281729-pull-html-content-and-style-from-other-website/#findComment-1447877 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.