View Full Version : Ajax to extract a div from another page possible?
gilgalbiblewhee
02-12-2008, 01:32 PM
Would it be possible to use Ajax and take a portion such as in a div from another page?
Inigoesdr
02-12-2008, 01:35 PM
Sure, as long as the other page is on the same domain.
It is possible to grab HTML information from other domains as well, but in this case you need a server-side application (written in php, asp...) which receives the AJAX request, sends it to another server, gets the response and sends it back to the AJAX object.
gilgalbiblewhee
02-12-2008, 10:21 PM
Is there any tutorial related to this ( Ajax and php )? I asked this question in the php section but I think my post got deleted without me getting any further.
I found myself a ready-made php application for that on doing a simply google (I wanted not to reinvent the wheel)... I can not give you the link towards right now, as I am home, not at the office, but gimme a PM to remind me, and I might point you to that. Fell free to google yourself for, but you must know the basis of php to work with...
liorean
02-12-2008, 10:50 PM
I asked this question in the php section but I think my post got deleted without me getting any further.Actually you posted it here in the same forum, and it got deleted as an obvious dupe, seeing two threads right next to each other with the same subject and similar contents tends to make me do that.
gilgalbiblewhee
02-13-2008, 12:16 AM
Actually you posted it here in the same forum, and it got deleted as an obvious dupe, seeing two threads right next to each other with the same subject and similar contents tends to make me do that.
It wasn't intentional. I posted in the php section. I read the answer in my email. But when I clicked the link it wasn't there. But fortunately I had a tab already open. So I copied from that content and pasted it the the AJAX section.
Here's a link for the article and php applications:
http://www.troywolf.com/articles/php/class_http/
I tested and used that successfully, together with AJAX in one of my sites.
gilgalbiblewhee
03-24-2008, 11:23 PM
Here's a link for the article and php applications:
http://www.troywolf.com/articles/php/class_http/
I tested and used that successfully, together with AJAX in one of my sites.
I finally got a chance to look at the script and I tested it. I have two pages:
class_http.php
example.php
I pasted every other bits of codes mentioned in your link in the example page.
But if I'm going to simply pick up, let's say the div tags from another page how would that be possible? Which scripts apply to that?
A1ien51
03-25-2008, 03:08 AM
Screen scraping is not very nice thing to do....You should get permission before taking someone else's content and causing extra load on their servers....
Eric
gilgalbiblewhee
03-25-2008, 04:39 AM
I want to use it from my own pages. I give myself the permission.
A1ien51
03-25-2008, 06:52 AM
I want to use it from my own pages. I give myself the permission.
If it is from your own pages, than why don;t you build yourself a JSON servoce or a web service to get the info. There is no need to scrape a page when you own the code.
Eric
gilgalbiblewhee
03-25-2008, 07:32 AM
If it is from your own pages, than why don;t you build yourself a JSON servoce or a web service to get the info. There is no need to scrape a page when you own the code.
Eric
JSON? Is that what it's called? Ok I'll look into it. Thanks.
gilgalbiblewhee
03-25-2008, 07:17 PM
Ok I looked into JSON. From what I've seen JSON isn't what I'm looking for. My intention of grabbing information from one source to the next is from my own domain is to populate them in a database. I have a 700 paged ebook converted to html. So I want to grab all the div tags automatically instead of me doing things manually. DO you understand what I'm saying?
We do understand. It is possible, but... do you have "700 paged ebook" and no DataBase?
gilgalbiblewhee
03-26-2008, 03:55 AM
We do understand. It is possible, but... do you have "700 paged ebook" and no DataBase?
What do you mean?
Actually I want to populate the database table so that I can search any word and it would show the result.
A1ien51
03-26-2008, 04:34 PM
Why wouldn't you write some serverside script or client app that does this. pretty strange you would use JavaScript to read html and send it to the server.
Use php to grab the page, read the contents with whatever indexing you are doing and than move onto the next.
I would leave the indexing to a serverside only process and make the future search capability Ajax based. :)
Eric
gilgalbiblewhee
03-26-2008, 06:29 PM
Why wouldn't you write some serverside script or client app that does this. pretty strange you would use JavaScript to read html and send it to the server.
Use php to grab the page, read the contents with whatever indexing you are doing and than move onto the next.
I would leave the indexing to a serverside only process and make the future search capability Ajax based. :)
Eric
How about php? How?
gilgalbiblewhee
04-03-2008, 07:29 AM
Here's a link for the article and php applications:
http://www.troywolf.com/articles/php/class_http/
I tested and used that successfully, together with AJAX in one of my sites.
I want to make the page redirect incrementally every, let's say 5 seconds.
How would I be able to achieve this?
Once the number reaches 10 and 100 I have to drop a "0" from "page0000". $i represents the number of page to be changed incrementally.
require_once('class_http.php');
$h = new http();
$i=2;
$link = "http://.../new/page0000".$i.".htm";
if (!$h->fetch($link)) {
echo "<h2>There is a problem with the http request!</h2>";
echo $h->log;
exit();
}
$result = $h->body;
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.