auto click a link through perl - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

auto click a link through perl

blackcharlieblackcharlie Posts: 4Member
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!

Comments

  • mdw1982mdw1982 Posts: 124Member
    : 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!"

  • blackcharlieblackcharlie Posts: 4Member
    : : 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.



  • mdw1982mdw1982 Posts: 124Member
    [b][red]This message was edited by mdw1982 at 2004-2-18 12:7:31[/red][/b][hr]
    : : : 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:

    [code]
    Link Text
    [/code]

    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.

    [code]
    $incoming_EnvVar = $ENV{'HTTP_REFERER'};
    if ( $incoming_EnvVar ne "" )
    {
    # do something with the value
    }
    else
    {
    # $incoming_EnvVar is MT - nothing to do
    exit;
    }
    [/code]

    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!"



  • JonathanJonathan Posts: 2,914Member
    : : : 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.
    :
    This is really...icky....if you mean what I think you do. So just to confirm, the input to your script is a HTML page (as in your have some HTML source in a variable). You then screen scrape it and find the onClick handlers. You then wish to execute these.

    Problem. The onClick handlers are most likely written in JavaScript. Thus you can't just call them as functions in your Perl script, as you need a JavaScript engine to execute them. For once, I'm not too sure I have a solution...

    Is this your problem, though? Or am I mis-understanding?

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • JonathanJonathan Posts: 2,914Member
    : 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.
    :
    Now *there* is a way to kill the performance of your web server!

    Just kidding... ;-)

    Jonathan


    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.