[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Mechanize confusion

Glen Holcomb

3/21/2008 6:06:00 PM

[Note: parts of this message were removed to make it a legal post.]

I will admit I've never used Mechanize before and if I am asking painfully
obvious feel free to push me out in traffic, however...

I have an odd issue. I have grabbed a form off of CDW's site and am trying
to fill out the proper info. The form shows the select list I want "_ct19"
but when I try to manipulate it mechanize acts like it doesn't exist

Here is the form:

#<WWW::Mechanize::Form
{name "HubPage"}
{method "POST"}
{action "default.aspx?hubpage=%2fhardware%2fprinters.html"}
{fields
#<WWW::Mechanize::Form::Field:0x33f0054
@name="__VIEWSTATE",
@value=

"/wEPDwUJODExNjM3MjQ1D2QWBAIBDxYCHgRUZXh0BRY8ZGl2IGlkPSdjLWNvbnRhaW5lcic+ZAI
DD2QWCgIBDw8WAh4HVmlzaWJsZWdkZAICDw8WAh8BZ2RkAgUPDxYCHwFnZBYCAgEPZBYCAgEPZBYCZg9
kFgJmD2QWCGYPZBYCZg8QZGQWAWZkAgEPZBYCZg8QZGQWAGQCAg9kFgJmDxBkZBYAZAIDD2QWAmYPDxY
CHwFoZGQCBg8PFgIfAWdkZAIHDw8WAh8BZ2RkZIrvUv5EI5fPxvnmGvx9951XbRWm">
#<WWW::Mechanize::Form::SelectList:0x3390af0
@name="_ctl9",
@options=
[#<WWW::Mechanize::Form::Option:0x33844e4
@select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
@selected=true,
@text="Select Brand",
@value="">,
#<WWW::Mechanize::Form::Option:0x3383ef4
@select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
@selected=false,
@text="Brady Industries",
@value="7633">,
#<WWW::Mechanize::Form::Option:0x33835f8
@select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
@selected=false,
@text="Brother International",
@value="5074">,
.
.
. Options
redacted for sanity's sake.
.
.
#<WWW::Mechanize::Form::Option:0x2d60d9c
@select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
@selected=false,
@text="Xerox Printers",
@value="6177">,
#<WWW::Mechanize::Form::Option:0x2d608ec
@select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
@selected=false,
@text="Zebra Technologies",
@value="6186">],
@value=[]>
#<WWW::Mechanize::Form::SelectList:0x2d5f76c
@name="_ctl12",
@options=[],
@value=[]>
#<WWW::Mechanize::Form::SelectList:0x2d5ddcc
@name="_ctl15",
@options=[],
@value=[]>}
{radiobuttons}
{checkboxes}
{file_uploads}
{buttons}>
=> nil
irb(main):050:0>



When I try to get details on either _ct19 or _VIEWSTATE I get an empty array
back:

toner_form.fields.name('_ct19')
=> []

toner_form.fields.name('_VIEWSTATE')
=> []

However with _ctl12 and _ctl15 everything appears to be happy:

toner_form.fields.name('_ctl15')
=> [#<WWW::Mechanize::Form::SelectList:0x2d5ddcc @value=[], @options=[],
@name="_ctl15">]

toner_form.fields.name('_ctl12')
=> [#<WWW::Mechanize::Form::SelectList:0x2d5f76c @value=[], @options=[],
@name="_ctl12">]


Does anyone have any idea how I can get to the select field I need?
--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."

-Greg Graffin (Bad Religion)

3 Answers

Aaron Patterson

3/21/2008 8:31:00 PM

0

On Sat, Mar 22, 2008 at 03:06:00AM +0900, Glen Holcomb wrote:
> I will admit I've never used Mechanize before and if I am asking painfully
> obvious feel free to push me out in traffic, however...
>
> I have an odd issue. I have grabbed a form off of CDW's site and am trying
> to fill out the proper info. The form shows the select list I want "_ct19"
> but when I try to manipulate it mechanize acts like it doesn't exist
>
> Here is the form:
>
> #<WWW::Mechanize::Form
> {name "HubPage"}
> {method "POST"}
> {action "default.aspx?hubpage=%2fhardware%2fprinters.html"}
> {fields
> #<WWW::Mechanize::Form::Field:0x33f0054
> @name="__VIEWSTATE",
> @value=
>
> "/wEPDwUJODExNjM3MjQ1D2QWBAIBDxYCHgRUZXh0BRY8ZGl2IGlkPSdjLWNvbnRhaW5lcic+ZAI
> DD2QWCgIBDw8WAh4HVmlzaWJsZWdkZAICDw8WAh8BZ2RkAgUPDxYCHwFnZBYCAgEPZBYCAgEPZBYCZg9
> kFgJmD2QWCGYPZBYCZg8QZGQWAWZkAgEPZBYCZg8QZGQWAGQCAg9kFgJmDxBkZBYAZAIDD2QWAmYPDxY
> CHwFoZGQCBg8PFgIfAWdkZAIHDw8WAh8BZ2RkZIrvUv5EI5fPxvnmGvx9951XbRWm">
> #<WWW::Mechanize::Form::SelectList:0x3390af0
> @name="_ctl9",
> @options=
> [#<WWW::Mechanize::Form::Option:0x33844e4
> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
> @selected=true,
> @text="Select Brand",
> @value="">,
> #<WWW::Mechanize::Form::Option:0x3383ef4
> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
> @selected=false,
> @text="Brady Industries",
> @value="7633">,
> #<WWW::Mechanize::Form::Option:0x33835f8
> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
> @selected=false,
> @text="Brother International",
> @value="5074">,
> .
> .
> . Options
> redacted for sanity's sake.
> .
> .
> #<WWW::Mechanize::Form::Option:0x2d60d9c
> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
> @selected=false,
> @text="Xerox Printers",
> @value="6177">,
> #<WWW::Mechanize::Form::Option:0x2d608ec
> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
> @selected=false,
> @text="Zebra Technologies",
> @value="6186">],
> @value=[]>
> #<WWW::Mechanize::Form::SelectList:0x2d5f76c
> @name="_ctl12",
> @options=[],
> @value=[]>
> #<WWW::Mechanize::Form::SelectList:0x2d5ddcc
> @name="_ctl15",
> @options=[],
> @value=[]>}
> {radiobuttons}
> {checkboxes}
> {file_uploads}
> {buttons}>
> => nil
> irb(main):050:0>
>
>
>
> When I try to get details on either _ct19 or _VIEWSTATE I get an empty array
> back:
>
> toner_form.fields.name('_ct19')
> => []
>
> toner_form.fields.name('_VIEWSTATE')
> => []
>
> However with _ctl12 and _ctl15 everything appears to be happy:
>
> toner_form.fields.name('_ctl15')
> => [#<WWW::Mechanize::Form::SelectList:0x2d5ddcc @value=[], @options=[],
> @name="_ctl15">]
>
> toner_form.fields.name('_ctl12')
> => [#<WWW::Mechanize::Form::SelectList:0x2d5f76c @value=[], @options=[],
> @name="_ctl12">]
>
>
> Does anyone have any idea how I can get to the select field I need?

It looks like you have a typo.

toner_form.fields.name('_VIEWSTATE')

should probably be:

toner_form.fields.name('__VIEWSTATE')

Note the two underscores.

Hope that helps.

--
Aaron Patterson
http://tenderlovem...

Rob Biedenharn

3/21/2008 8:48:00 PM

0

On Mar 21, 2008, at 4:31 PM, Aaron Patterson wrote:
> On Sat, Mar 22, 2008 at 03:06:00AM +0900, Glen Holcomb wrote:
>> I will admit I've never used Mechanize before and if I am asking
>> painfully
>> obvious feel free to push me out in traffic, however...
>>
>> I have an odd issue. I have grabbed a form off of CDW's site and
>> am trying
>> to fill out the proper info. The form shows the select list I want
>> "_ct19"
>> but when I try to manipulate it mechanize acts like it doesn't exist
>>
>> Here is the form:
>>
>> #<WWW::Mechanize::Form
>> {name "HubPage"}
>> {method "POST"}
>> {action "default.aspx?hubpage=%2fhardware%2fprinters.html"}
>> {fields
>> #<WWW::Mechanize::Form::Field:0x33f0054
>> @name="__VIEWSTATE",
>> @value=
>>
>> "/
>> wEPDwUJODExNjM3MjQ1D2QWBAIBDxYCHgRUZXh0BRY8ZGl2IGlkPSdjLWNvbnRhaW5lcic
>> +ZAI
>> DD2QWCgIBDw8WAh4HVmlzaWJsZWdkZAICDw8WAh8BZ2RkAgUPDxYCHwFnZBYCAgEPZBYCAgEPZBYCZg9
>> kFgJmD2QWCGYPZBYCZg8QZGQWAWZkAgEPZBYCZg8QZGQWAGQCAg9kFgJmDxBkZBYAZAIDD2QWAmYPDxY
>> CHwFoZGQCBg8PFgIfAWdkZAIHDw8WAh8BZ2RkZIrvUv5EI5fPxvnmGvx9951XbRWm">
>> #<WWW::Mechanize::Form::SelectList:0x3390af0
>> @name="_ctl9",
>> @options=
>> [#<WWW::Mechanize::Form::Option:0x33844e4
>> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
>> @selected=true,
>> @text="Select Brand",
>> @value="">,
>> #<WWW::Mechanize::Form::Option:0x3383ef4
>> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
>> @selected=false,
>> @text="Brady Industries",
>> @value="7633">,
>> #<WWW::Mechanize::Form::Option:0x33835f8
>> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
>> @selected=false,
>> @text="Brother International",
>> @value="5074">,
>> .
>> .
>> . Options
>> redacted for sanity's sake.
>> .
>> .
>> #<WWW::Mechanize::Form::Option:0x2d60d9c
>> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
>> @selected=false,
>> @text="Xerox Printers",
>> @value="6177">,
>> #<WWW::Mechanize::Form::Option:0x2d608ec
>> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
>> @selected=false,
>> @text="Zebra Technologies",
>> @value="6186">],
>> @value=[]>
>> #<WWW::Mechanize::Form::SelectList:0x2d5f76c
>> @name="_ctl12",
>> @options=[],
>> @value=[]>
>> #<WWW::Mechanize::Form::SelectList:0x2d5ddcc
>> @name="_ctl15",
>> @options=[],
>> @value=[]>}
>> {radiobuttons}
>> {checkboxes}
>> {file_uploads}
>> {buttons}>
>> => nil
>> irb(main):050:0>
>>
>>
>>
>> When I try to get details on either _ct19 or _VIEWSTATE I get an
>> empty array
>> back:
>>
>> toner_form.fields.name('_ct19')
>> => []
>>
>> toner_form.fields.name('_VIEWSTATE')
>> => []
>>
>> However with _ctl12 and _ctl15 everything appears to be happy:
>>
>> toner_form.fields.name('_ctl15')
>> => [#<WWW::Mechanize::Form::SelectList:0x2d5ddcc @value=[],
>> @options=[],
>> @name="_ctl15">]
>>
>> toner_form.fields.name('_ctl12')
>> => [#<WWW::Mechanize::Form::SelectList:0x2d5f76c @value=[],
>> @options=[],
>> @name="_ctl12">]
>>
>>
>> Does anyone have any idea how I can get to the select field I need?
>
> It looks like you have a typo.
>
> toner_form.fields.name('_VIEWSTATE')
>
> should probably be:
>
> toner_form.fields.name('__VIEWSTATE')
>
> Note the two underscores.
>
> Hope that helps.
>
> --
> Aaron Patterson
> http://tenderlovem...

And its _ctl9 not _ct19. (or '_CTL9'.downcase not '_ct'+ 19.to_s)

-Rob

Rob Biedenharn http://agileconsult...
Rob@AgileConsultingLLC.com



Glen Holcomb

3/21/2008 9:12:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

On Fri, Mar 21, 2008 at 2:47 PM, Rob Biedenharn <Rob@agileconsultingllc.com>
wrote:

> On Mar 21, 2008, at 4:31 PM, Aaron Patterson wrote:
> > On Sat, Mar 22, 2008 at 03:06:00AM +0900, Glen Holcomb wrote:
> >> I will admit I've never used Mechanize before and if I am asking
> >> painfully
> >> obvious feel free to push me out in traffic, however...
> >>
> >> I have an odd issue. I have grabbed a form off of CDW's site and
> >> am trying
> >> to fill out the proper info. The form shows the select list I want
> >> "_ct19"
> >> but when I try to manipulate it mechanize acts like it doesn't exist
> >>
> >> Here is the form:
> >>
> >> #<WWW::Mechanize::Form
> >> {name "HubPage"}
> >> {method "POST"}
> >> {action "default.aspx?hubpage=%2fhardware%2fprinters.html"}
> >> {fields
> >> #<WWW::Mechanize::Form::Field:0x33f0054
> >> @name="__VIEWSTATE",
> >> @value=
> >>
> >> "/
> >> wEPDwUJODExNjM3MjQ1D2QWBAIBDxYCHgRUZXh0BRY8ZGl2IGlkPSdjLWNvbnRhaW5lcic
> >> +ZAI
> >>
> DD2QWCgIBDw8WAh4HVmlzaWJsZWdkZAICDw8WAh8BZ2RkAgUPDxYCHwFnZBYCAgEPZBYCAgEPZBYCZg9
> >>
> kFgJmD2QWCGYPZBYCZg8QZGQWAWZkAgEPZBYCZg8QZGQWAGQCAg9kFgJmDxBkZBYAZAIDD2QWAmYPDxY
> >> CHwFoZGQCBg8PFgIfAWdkZAIHDw8WAh8BZ2RkZIrvUv5EI5fPxvnmGvx9951XbRWm">
> >> #<WWW::Mechanize::Form::SelectList:0x3390af0
> >> @name="_ctl9",
> >> @options=
> >> [#<WWW::Mechanize::Form::Option:0x33844e4
> >> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
> >> @selected=true,
> >> @text="Select Brand",
> >> @value="">,
> >> #<WWW::Mechanize::Form::Option:0x3383ef4
> >> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
> >> @selected=false,
> >> @text="Brady Industries",
> >> @value="7633">,
> >> #<WWW::Mechanize::Form::Option:0x33835f8
> >> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
> >> @selected=false,
> >> @text="Brother International",
> >> @value="5074">,
> >> .
> >> .
> >> . Options
> >> redacted for sanity's sake.
> >> .
> >> .
> >> #<WWW::Mechanize::Form::Option:0x2d60d9c
> >> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
> >> @selected=false,
> >> @text="Xerox Printers",
> >> @value="6177">,
> >> #<WWW::Mechanize::Form::Option:0x2d608ec
> >> @select_list=#<WWW::Mechanize::Form::SelectList:0x3390af0 ...>,
> >> @selected=false,
> >> @text="Zebra Technologies",
> >> @value="6186">],
> >> @value=[]>
> >> #<WWW::Mechanize::Form::SelectList:0x2d5f76c
> >> @name="_ctl12",
> >> @options=[],
> >> @value=[]>
> >> #<WWW::Mechanize::Form::SelectList:0x2d5ddcc
> >> @name="_ctl15",
> >> @options=[],
> >> @value=[]>}
> >> {radiobuttons}
> >> {checkboxes}
> >> {file_uploads}
> >> {buttons}>
> >> => nil
> >> irb(main):050:0>
> >>
> >>
> >>
> >> When I try to get details on either _ct19 or _VIEWSTATE I get an
> >> empty array
> >> back:
> >>
> >> toner_form.fields.name('_ct19')
> >> => []
> >>
> >> toner_form.fields.name('_VIEWSTATE')
> >> => []
> >>
> >> However with _ctl12 and _ctl15 everything appears to be happy:
> >>
> >> toner_form.fields.name('_ctl15')
> >> => [#<WWW::Mechanize::Form::SelectList:0x2d5ddcc @value=[],
> >> @options=[],
> >> @name="_ctl15">]
> >>
> >> toner_form.fields.name('_ctl12')
> >> => [#<WWW::Mechanize::Form::SelectList:0x2d5f76c @value=[],
> >> @options=[],
> >> @name="_ctl12">]
> >>
> >>
> >> Does anyone have any idea how I can get to the select field I need?
> >
> > It looks like you have a typo.
> >
> > toner_form.fields.name('_VIEWSTATE')
> >
> > should probably be:
> >
> > toner_form.fields.name('__VIEWSTATE')
> >
> > Note the two underscores.
> >
> > Hope that helps.
> >
> > --
> > Aaron Patterson
> > http://tenderlovem...
>
> And its _ctl9 not _ct19. (or '_CTL9'.downcase not '_ct'+ 19.to_s)
>
> -Rob
>
> Rob Biedenharn http://agileconsult...
> Rob@AgileConsultingLLC.com
>
>
>
>
Thanks for being gentle guys. Might be time for a new monitor or glasses.

--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."

-Greg Graffin (Bad Religion)