inherit
151915
0
Oct 10, 2012 11:55:19 GMT -8
Topeka
Personal Text``
62
February 2010
topeka
|
Post by Topeka on Feb 12, 2010 19:05:58 GMT -8
Does anyone know if its possible to retrive website info from one website, and place it in another?
Like, I have a website that would have a bunch of numbers on it. I wanted to know if i could first get the data from the first site, and place it in the second site. And if the data changed from the first Site, It would do the same in the second.
Does anyone know if its possible, and if so, does anyone either want to help with it, or point me in the right direction so i can do it?
I can get more indepth of what im doing, but i figured if no one could help in the first place then i wouldnt fully explain it. But if someone does, i can explain it fully.
Thanks
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Feb 12, 2010 23:48:20 GMT -8
If you have control of both sites, it'd be easier. Make a feed of some sort that contains all the data in a condensed format. For example, an RSS feed: <rss> <stat1>10</stat1> <test>1034</test> <members>400</members> </rss>
And use an RSS feed reader on the second site to display this data.
Or to be more condensed (to save bandwidth and increase loading speeds): 10;1034;400 Separate the numbers of semicolons and just remember which number is which (first is stat1, second is test, third is members, etc.).
If you aren't in control of both websites, you'll have to download the entire page and retrieve the information from it in RegEx. The way you'd do this differs from site to site, so I won't bother typing up a whole code.
What you'll need in all scenarios is PHP's file_get_content's function.
// yoursite.com $page = file_get_contents("http://somesite.com/thedata.php");
Then manipulate the $page string until you've retrieved the necessary information.
|
|
inherit
151915
0
Oct 10, 2012 11:55:19 GMT -8
Topeka
Personal Text``
62
February 2010
topeka
|
Post by Topeka on Feb 13, 2010 9:47:57 GMT -8
What i am doing is taking data from my own site, and placing it in a proboards site. ill start looking up the php $_get, and the rss feed and start messing around with it.
Thanks for your help Charles. If i dont get it after awhile, ill repost asking where i would be going wrong. Thanks again.
Edit:
So as a test type thing i tried a simple ajax script from a tut to see a bit of how it works. The 2 sites have very little data on them, but why when i press the button to change the content on proboards, it gives me Access is Denied as a stat error.
I looked, and i didnt see anything breaking proboard rules. So, is it going to be from the sites that im obtaining the data from the problem?
ones a published excel doc, other is the w3school. txt that they used in the tut.
<script type="text/javascript"> function loadXMLDoc(url) { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET",url,false); xmlhttp.send(null); document.getElementById('test').innerHTML=xmlhttp.responseText; } </script>
<div id="test"> <h2>Click to let AJAX change this text</h2> </div> <button type="button" onclick="loadXMLDoc('mhtml:http://www.berch.biz/current.mht')">Click Me</button> <button type="button" onclick="loadXMLDoc('http://www.w3schools.com/ajax/test1.txt')">Click Me</button>
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Feb 14, 2010 10:10:06 GMT -8
Ah. Well file_get_contents is only useful if you can execute PHP on the *retrieving* site. ProBoards doesn't give you PHP access (and rightfully so), so you'll have to resort to another method. Ajax, what you're using, isn't allowed on separate domains, as a security feature. Site proboards.com cannot communicate with site yoursite.com via Ajax. Off the top of my head, I would do it like so: On yoursite.com/yourscript.js:var data = [];<?php $data = Array('this' => 'is', 'the' => 'data', 'you' => 'want', 'displayed' => 'on', 'your' => 'ProBoard'); foreach ($data as $key => $value) echo "\n", 'data["', str_replace('"', '\"', $key), '"] = "', str_replace('"', '\"', $value), '";'; ?> On ProBoards:<script src="http://yoursite.com/yourscript.js" type="text/javascript"></script> <script type="text/javascript"><!-- for (d in data) document.write(d + ' is equal to ' + data[d] + '<br />'); //--></script> And use the information as such, via the data array.
|
|
inherit
151915
0
Oct 10, 2012 11:55:19 GMT -8
Topeka
Personal Text``
62
February 2010
topeka
|
Post by Topeka on Feb 16, 2010 12:59:21 GMT -8
Ok, thanks, ill start working on it and see what i can accomplish by myself. Thanks.
|
|