Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,613 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 953 people online right now. Registration is fast and FREE... Join Now!




Alternative to WWW::Mechanize

 
Reply to this topicStart new topic

Alternative to WWW::Mechanize, For finding form field types

Saiki
post 28 Jun, 2008 - 07:45 PM
Post #1


New D.I.C Head

*
Joined: 25 May, 2008
Posts: 2

Is there a better way to finding out what a field's type is? Err, lemme rephrase that (with added background info too biggrin.gif).

I have a small script here that uses Mech to find all the fields on the form on the website. The code in question is:

CODE
@fields = $mech->find_all_inputs();


Now, what that returns is not that helpful:

CODE
HTML::Form::TextInput=HASH(0x87b6ba8)    
HTML::Form::ListInput=HASH(0x87bae78)
HTML::Form::SubmitInput=HASH(0x87bb460)
HTML::Form::TextInput=HASH(0x87bf770)
HTML::Form::ListInput=HASH(0x87bbd48)
HTML::Form::ListInput=HASH(0x87bf740)
HTML::Form::SubmitInput=HASH(0x87bf8a8)
HTML::Form::TextInput=HASH(0x87c049c)
HTML::Form::ListInput=HASH(0x87c0388)
HTML::Form::SubmitInput=HASH(0x87c03c4)
HTML::Form::TextInput=HASH(0x87ce480)
HTML::Form::ListInput=HASH(0x87ce1a4)
HTML::Form::SubmitInput=HASH(0x87ce2f4)


So now I know if the field is either a textbox, some sort of list, or a submit button. But the site has both dropdown fields and radio button fields. Anyway to distinguish between them? Is there a better way to gather the field types?

EDIT: Lol@New D.I.C. Head. Oh, and is there a way to select a dropdown option by its number on the list, rather than what it says?

This post has been edited by Saiki: 28 Jun, 2008 - 07:58 PM
User is offlineProfile CardPM

Go to the top of the page

KevinADC
post 29 Jun, 2008 - 08:50 AM
Post #2


D.I.C Head

Group Icon
Joined: 23 Jan, 2007
Posts: 213



Thanked 3 times

Dream Kudos: 50
My Contributions


QUOTE(Saiki @ 28 Jun, 2008 - 08:45 PM) *

Is there a better way to finding out what a field's type is? Err, lemme rephrase that (with added background info too biggrin.gif).

I have a small script here that uses Mech to find all the fields on the form on the website. The code in question is:

CODE
@fields = $mech->find_all_inputs();


Now, what that returns is not that helpful:

CODE
HTML::Form::TextInput=HASH(0x87b6ba8)    
HTML::Form::ListInput=HASH(0x87bae78)
HTML::Form::SubmitInput=HASH(0x87bb460)
HTML::Form::TextInput=HASH(0x87bf770)
HTML::Form::ListInput=HASH(0x87bbd48)
HTML::Form::ListInput=HASH(0x87bf740)
HTML::Form::SubmitInput=HASH(0x87bf8a8)
HTML::Form::TextInput=HASH(0x87c049c)
HTML::Form::ListInput=HASH(0x87c0388)
HTML::Form::SubmitInput=HASH(0x87c03c4)
HTML::Form::TextInput=HASH(0x87ce480)
HTML::Form::ListInput=HASH(0x87ce1a4)
HTML::Form::SubmitInput=HASH(0x87ce2f4)


So now I know if the field is either a textbox, some sort of list, or a submit button. But the site has both dropdown fields and radio button fields. Anyway to distinguish between them? Is there a better way to gather the field types?

EDIT: Lol@New D.I.C. Head. Oh, and is there a way to select a dropdown option by its number on the list, rather than what it says?


The modules documentation explains how to return specific elements of a form using using the find_all_inputs() method. I don't know if it can distinguish list inputs from each other, like radio, checkbox, select, but you can try and see if it will. There is also mech-dump which is discussed in more detail in the www::machanize::faqs documentation. I have never used it so can't offer any examples.

http://search.cpan.org/~petdance/WWW-Mecha..._form_correctly?
User is offlineProfile CardPM

Go to the top of the page

Saiki
post 29 Jun, 2008 - 01:27 PM
Post #3


New D.I.C Head

*
Joined: 25 May, 2008
Posts: 2

QUOTE(KevinADC @ 29 Jun, 2008 - 09:50 AM) *


The modules documentation explains how to return specific elements of a form using using the find_all_inputs() method. I don't know if it can distinguish list inputs from each other, like radio, checkbox, select, but you can try and see if it will. There is also mech-dump which is discussed in more detail in the www::machanize::faqs documentation. I have never used it so can't offer any examples.

http://search.cpan.org/~petdance/WWW-Mecha..._form_correctly?


Oh I see. I already tried mech-dump but it did not really work as the form was dynamic. Thanks for the help though.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 02:48AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month