CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
help with mechanize

 



jubegnx
Novice

Feb 14, 2007, 10:47 PM

Post #1 of 22 (2116 views)
help with mechanize Can't Post

i noticed that WWW::Mechanize does not support JavaScript, can anyone tell me what i can use to automate forms/pages written in JavaScript...


KevinR
Veteran


Feb 14, 2007, 11:30 PM

Post #2 of 22 (2113 views)
Re: [jubegnx] help with mechanize [In reply to] Can't Post

I think a lot of people want to know that, if you find out post it here. Wink
-------------------------------------------------


jubegnx
Novice

Feb 14, 2007, 11:52 PM

Post #3 of 22 (2112 views)
Re: [KevinR] help with mechanize [In reply to] Can't Post

awww shucks, r u serious? thats a real kick in the nuggets..


KevinR
Veteran


Feb 15, 2007, 12:40 AM

Post #4 of 22 (2109 views)
Re: [jubegnx] help with mechanize [In reply to] Can't Post

read it and weep Unsure

http://search.cpan.org/~petdance/WWW-Mechanize-1.20/lib/WWW/Mechanize/FAQ.pod

excert:


Quote
NAME ^

WWW::Mechanize::FAQ - Frequently Asked Questions about WWW::Mechanize
JavaScript ^
I have this web page that has JavaScript on it, and my Mech program doesn't work.

That's because WWW::Mechanize doesn't operate on the JavaScript. It only understands the HTML parts of the page.
I thought Mech was supposed to work like a web browser.

It does pretty much, but it doesn't support JavaScript.

I added some basic attempts at picking up URLs in window.open() calls and return them in $mech->links. They work sometimes. Beyond that, there's no support for JavaScript.
Are you going to add JavaScript support?

I will if anyone sends me the code to do it. I'm not going to write a JavaScript processor myself.

-------------------------------------------------


jubegnx
Novice

Feb 20, 2007, 7:55 PM

Post #5 of 22 (2086 views)
Re: [KevinR] help with mechanize [In reply to] Can't Post

ok i have a new prob. now. when i run a script it returns an error once in a while. how would i read that error and make an input that would overide it. for example some error pops up and iwould like to read the specific error within the script and make the script continue with its business... pls help me out thx..


KevinR
Veteran


Feb 20, 2007, 8:42 PM

Post #6 of 22 (2084 views)
Re: [jubegnx] help with mechanize [In reply to] Can't Post

are you talking about a perl error or some other error?
-------------------------------------------------


jubegnx
Novice

Feb 21, 2007, 7:53 AM

Post #7 of 22 (2081 views)
Re: [KevinR] help with mechanize [In reply to] Can't Post

yep perl error just comes up once in a while so how would i make the script read that error and just ignore it


KevinR
Veteran


Feb 21, 2007, 12:01 PM

Post #8 of 22 (2079 views)
Re: [jubegnx] help with mechanize [In reply to] Can't Post

more detail: what error is perl returning once in a while? Errors like that are usually generated by input, so what is being inputted that causes an error?
-------------------------------------------------


jubegnx
Novice

Feb 21, 2007, 4:23 PM

Post #9 of 22 (2073 views)
Re: [KevinR] help with mechanize [In reply to] Can't Post

ok i used the File::RandomLine to randomly select a line from a text file and then use that line in a loop... ever since that it started showing errors once in a while --> this is the line in the loop -->

$rl = File::RandomLine->new('file.txt', {algorithm=>"uniform"});
$key = $rl->next;;


the error states that it cant find the key, but the key is indeed there so how would i fix that.


KevinR
Veteran


Feb 21, 2007, 8:37 PM

Post #10 of 22 (2070 views)
Re: [jubegnx] help with mechanize [In reply to] Can't Post

hmmm.... I don't know. Try this though:


Code
$rl = File::RandomLine->new('file.txt', {algorithm=>"uniform"}) or die "Can't get a randome line: $!"; 
$key = $rl->next;


maybe the file is locked by another process when you try and access it?
-------------------------------------------------


jubegnx
Novice

Feb 21, 2007, 10:55 PM

Post #11 of 22 (2068 views)
Re: [KevinR] help with mechanize [In reply to] Can't Post

sorry to be a pain in the ass.. but what i was tryin to figure out is how would i tell the script that once that error occurs to continue with the loop instead of just closing.


KevinR
Veteran


Feb 22, 2007, 12:11 AM

Post #12 of 22 (2067 views)
Re: [jubegnx] help with mechanize [In reply to] Can't Post

try:


Code
$rl = File::RandomLine->new('file.txt', {algorithm=>"uniform"}) or next; 
$key = $rl->next;

-------------------------------------------------


jubegnx
Novice

Feb 22, 2007, 3:15 PM

Post #13 of 22 (2057 views)
Re: [KevinR] help with mechanize [In reply to] Can't Post

hey kev thx that last one worked... now i have another problem.
im trying to use mechanize to pull one line of text from an email.
the line goes like this and it is text not a link format on the page

http://one.two.com/reloc.cfm?c=3&code=141FB7CB-5109-4B81-B758-D1D24E32398E

so now what would the perl command be to only take that one line out.. this is what i have but its wrong

$page = $agent->content;
$page =~ qr/one.two.com./;
$link = $2;

also the long code after "code=" always changes but its in the same format


KevinR
Veteran


Feb 22, 2007, 7:05 PM

Post #14 of 22 (2041 views)
Re: [jubegnx] help with mechanize [In reply to] Can't Post

maybe:


Code
$page = $agent->content; 
if ($page =~ m|(\Qhttp://one.two.com/reloc.cfm?c=\E\d+\Q&code=\E\S+)|) {
$link = $1;
}


depends on what else is in $page.
-------------------------------------------------


(This post was edited by KevinR on Feb 22, 2007, 7:07 PM)


jubegnx
Novice

Feb 22, 2007, 7:07 PM

Post #15 of 22 (2038 views)
Re: [jubegnx] help with mechanize [In reply to] Can't Post

nevermind got it... played with the numerous pattern matching techniques and finally got it to chop out just the one line...


jubegnx
Novice

Feb 22, 2007, 7:08 PM

Post #16 of 22 (2037 views)
Re: [jubegnx] help with mechanize [In reply to] Can't Post

lol we were writing both at the same time.. thank you for your help!


KevinR
Veteran


Feb 22, 2007, 10:33 PM

Post #17 of 22 (2034 views)
Re: [jubegnx] help with mechanize [In reply to] Can't Post

You're welcome Cool
-------------------------------------------------


jubegnx
Novice

Feb 23, 2007, 5:01 PM

Post #18 of 22 (2027 views)
Re: [KevinR] help with mechanize [In reply to] Can't Post

darnit its me again... that code you gave me with the die and next on it doesnt work i thought it did... but check it out, this is exactly word for word my problem i found this accidently but its quite old

http://www.mail-archive.com/libwww@perl.org/msg04690.html

so do you know if they addressed that in some way because i have the most recent version of mechanize?
thx


KevinR
Veteran


Feb 23, 2007, 8:48 PM

Post #19 of 22 (2026 views)
Re: [jubegnx] help with mechanize [In reply to] Can't Post

sorry, I don't know.
-------------------------------------------------


jubegnx
Novice

Mar 4, 2007, 7:25 PM

Post #20 of 22 (1995 views)
Re: [KevinR] help with mechanize [In reply to] Can't Post

i have a question again... how can i use perl to read a javascript drop down menu from a web page and select one of the options on the menu? i was looking through cpan but i dont know which module to use


davorg
Thaumaturge / Moderator

Mar 6, 2007, 5:29 AM

Post #21 of 22 (1988 views)
Re: [jubegnx] help with mechanize [In reply to] Can't Post

If you have a new question then please post it as a new question - not as a follow-up to an old question.

WWW::Mechanise doesn't seem to understand any Javascript, so it looks like you are out of luck.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


birkuscircus
Novice

Oct 12, 2007, 3:57 PM

Post #22 of 22 (1860 views)
Re: [davorg] help with mechanize [In reply to] Can't Post

Hey, I don't know if this is helpful or not, but I had a form written in javascrip that I needed to fill out, and I read in this post that it couldn't be done with WWW::Mechanize and kind of paniced, but I got it to work out.

Try right clicking on the page source of the page with the forms you want to fill out, then click on "Page Info." If you go to the forms tab, it lists all the available forms...and in my case at least, even the ones within the javascript. Might not work in most cases, but i guess it's worth a shot.

Hope it helps. :)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives