This message was edited by mdw1982 at 2004-2-18 12:7:31
: : : I'm looking to write a script that will perform the action of clicking on a link of an html page, from where I can do a screen scrape of what i want & process it. I have the last part down, just need that link click part.
: : :
: : : thanks!
: : :
: :
: : I'm really curious here, but are you talking about an event handler where something happens on a page to trigger an event and then action is taken by a script?
: : --
: : Mark
: : "If I can't code I'm not going to be a happy camper!"
: :
: :
:
: yes. for a given html page, I need to have the ability to 'trigger an event' - the onClick() event, which will send me to that resulting href.
: in perl.
ok...it sounds as though you want to know "where" the onClick event has come from. Therea are two ways I can think of to make this happen. If I'm understanding you correctly you want to know the value of the HTTP_REFERER Environment variable.
Mind you, I haven't tried this so its not tested; I'm thinking outload and off the top of my head. Your link might appear something like this:
<a href="somePage.html" onClick="script.pl">Link Text</a>
In your script you would have some code to receive the incoming Environment Variable and then you'd do what ever you'd need to with that value.
$incoming_EnvVar = $ENV{'HTTP_REFERER'};
if ( $incoming_EnvVar ne "" )
{
# do something with the value
}
else
{
# $incoming_EnvVar is MT - nothing to do
exit;
}
Unless I'm really missing it here the onClick event which is calling your script would receive the Environment Variable, which would be the URL of the page where the link was clicked.
The second method I might use to do this would be by embedding php into the .html page to gather the HTTP_REFERER value and pass it to the script you're using to process the value. The downside to this is that it only works if you've got the neccessary things setup for embedding php code in a normal html document.
Its not hard to make this happen. All that is needed is PHP to be installed and running on your webserver, and most do these days, and second, you simple create an .htaccess file in the directory where the .html page exists with this line in the file:
AddHandler application/x-httpd-php .html
That way, when ever apache sees php code embedded in a normal .html file it executes the php code as if it were an actual .php file.
--
Mark
"If I can't code I'm not going to be a happy camper!"