User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion

Reply
Thread Tools Display Modes
Unread 25 Aug 2004, 19:50   #1
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
Parsing other peoples pages and extracting content

I got a bit of a tricky problem.
I found this site which has this "phrase of the day". I want to see that phrase... on my desktop!

The phrase is deeply embedded in the website and I can only see it when I request the whole page. An IFrame is not an option because the site has a nr of popups plus that it's too wide to actually fit in a decent frame.

I got an HTML page as desktop background, so locally I can use HTML and Javascript to extract the phrase. However I have no idea how I would go about extracting the content with Javascript. If that's even possible.
I also have some hosted webspace with PHP ('lo Impulsed), but I have no idea if I can import pages with PHP (or if it's allowed by the hosting even).

So, my question is, how can I best do this? Is Javascript a possibility? Or should I resort to more powerfull toolage? And if so... which and how?

TY
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Unread 25 Aug 2004, 23:13   #2
Caesar2
Commander
 
Caesar2's Avatar
 
Join Date: Sep 2001
Location: Netherlands
Posts: 146
Caesar2 is just really niceCaesar2 is just really niceCaesar2 is just really niceCaesar2 is just really nice
Re: Parsing other peoples pages and extracting content

Use XMLHTTP. I used it with asp, but it can be done clientside with javascript aswell.
I found this at google:

Code:
<html>
<body>

<script>
var x = new ActiveXObject("Msxml2.XMLHTTP");
x.open("GET","http://www.microsoft.com",false);
x.send();
document.write(x.responseText);
</script>

</body>
</html>
__________________
Quote:
Originally posted by Cochese
Cathaar are not overpowered.

You were just "bashed", live with it.
Caesar2 is offline   Reply With Quote
Unread 26 Aug 2004, 01:32   #3
JetLinus
Friendly geek of GD :-/
 
JetLinus's Avatar
 
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
JetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud of
Arrow Re: Parsing other peoples pages and extracting content

Sorry for this low-quality-help, but I'm quite sure it can be done with PHP. Get site into a variable, then parse (well, you knew that).

I _do_ know who to do it using Visual Basic of course...
Quite simple using the MSInternetTransfer Control (buggy as hell, but what the heck as long as it works).

Code:
Dim WholePage As String

WholePage = MSInetTransfer.Open("http://www.myurl.com")
QuoteOfTheDay = Mid$( ... )  ' Use InStr() to find beginning and end markers...
__________________
[»] Entropy increases! :-/
JetLinus is offline   Reply With Quote
Unread 26 Aug 2004, 01:34   #4
JetLinus
Friendly geek of GD :-/
 
JetLinus's Avatar
 
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
JetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud of
Arrow Re: Parsing other peoples pages and extracting content

Just got a possible PHP solution:


Code:
$f = fopen("http://blahblah","r");
$text = fread($f, 65535);
fclose($f);
65536 is a buffer in this case.
Also look for class_snoopy, a sort of webbrowser control...
__________________
[»] Entropy increases! :-/
JetLinus is offline   Reply With Quote
Unread 26 Aug 2004, 09:55   #5
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
Re: Parsing other peoples pages and extracting content

Quote:
Originally Posted by JetLinus
Just got a possible PHP solution:


Code:
$f = fopen("http://blahblah","r");
$text = fread($f, 65535);
fclose($f);
65536 is a buffer in this case.
Also look for class_snoopy, a sort of webbrowser control...
yay!!!
It works. Thanks!
I got the page in a variable. I didn't know that fread could read web pages.
BTW, as a sidenote for those who want to use this feature too: if you use fread on a web page it stops reading after it has received a network packet. Use fread in a loop to collect the entire page and not only the first few bytes.
Code:
<?php
$handle = fopen("http://www.example.com/", "rb");
$contents = '';
while (!feof($handle)) {
  $contents .= fread($handle, 8192);
}
fclose($handle);
?>
From:
http://www.php.net/manual/en/function.fread.php
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Unread 2 Sep 2004, 13:24   #6
Sundipper
Hourly Fee : $450
 
Sundipper's Avatar
 
Join Date: Oct 2000
Posts: 15
Sundipper is an unknown quantity at this point
Re: Parsing other peoples pages and extracting content

If you're done with fopen(); try more at

http://www.hotscripts.com/PHP/Script...ing/index.html

they have a lot of examples there. The fopen(); function can be disabled to work with remote files on some servers.
__________________
SunDipping; A Way of Living.
Sundipper is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Forum Jump


All times are GMT +1. The time now is 09:30.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018