[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Clicking link with WWW::Mechanize

Peter Szinek

3/28/2007 10:44:00 AM

Hello,

I wuold like to click on a link in WWW::Mechaznie, and I know only the
Hpricot XPath of the element I would like to click, nothing more. While
it's certainly possible to look up the text of the element pointed to by
the XPath, there can be more elements with that text, but only one
element with that XPath.

Is this possible with Mechanize somehow?


Thanks,
Peter

__
http://www.rubyra... :: Ruby and Web2.0 blog
http://s... :: Ruby web scraping framework
http://rubykitch... :: The indexed archive of all things Ruby.

6 Answers

Aaron Patterson

3/28/2007 3:52:00 PM

0

Hi Peter,

On Wed, Mar 28, 2007 at 07:44:08PM +0900, Peter Szinek wrote:
> Hello,
>
> I wuold like to click on a link in WWW::Mechaznie, and I know only the
> Hpricot XPath of the element I would like to click, nothing more. While
> it's certainly possible to look up the text of the element pointed to by
> the XPath, there can be more elements with that text, but only one
> element with that XPath.
>
> Is this possible with Mechanize somehow?

Yes, this is possible. Mechanize can click an hpricot element, as long
as it has an 'href', or a 'src' attribute. For example:

page = mech.get('http://example...)
new_page = mech.click((page/'//some/xpath/a'))

If you've got more questions, don't forget about the mechanize mailing
list:

http://rubyforge.org/mailman/listinfo/mecha...

Hope that helps!

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

Peter Szinek

3/28/2007 7:58:00 PM

0

Aaron Patterson wrote:
> Hi Peter,
>
> On Wed, Mar 28, 2007 at 07:44:08PM +0900, Peter Szinek wrote:
>> Hello,
>>
>> I wuold like to click on a link in WWW::Mechaznie, and I know only the
>> Hpricot XPath of the element I would like to click, nothing more. While
>> it's certainly possible to look up the text of the element pointed to by
>> the XPath, there can be more elements with that text, but only one
>> element with that XPath.
>>
>> Is this possible with Mechanize somehow?
>
> Yes, this is possible. Mechanize can click an hpricot element, as long
> as it has an 'href', or a 'src' attribute. For example:
>
> page = mech.get('http://example...)
> new_page = mech.click((page/'//some/xpath/a'))

Hey, thanks Aaron! I am really glad that this is possible!

> If you've got more questions, don't forget about the mechanize mailing
> list:
>
> http://rubyforge.org/mailman/listinfo/mecha...

Sure, I am going to subscribe right now!

Cheers,
Peter
_
http://www.rubyra... :: Ruby and Web2.0 blog
http://s... :: Ruby web scraping framework
http://rubykitch... :: The indexed archive of all things Ruby.

TintinX

3/16/2012 9:42:00 AM

0

On 16 Mar 2012 04:12:07 GMT, rfischer@sonic.net (Ray Fischer) wrote:

> <Americans@USA.now> wrote:
>>So how long did it take this guy to figure it out?
>
>Not as long as most of the morons who are still republicans.

Proof? Thought not.
>
>
>>On Wed, 14 Mar 2012 14:43:55 +0000 (UTC), 2915 Dead <dead@gone.com> wrote:
>>

Tyron Dawn Deanda

3/17/2012 12:27:00 AM

0

Ray is a classic usenet zoo monkey. Liars, once they have been
exposed, frequently revert to behavior most similar to a zoo monkey
who sits in the cage throwing feces at passersby but saying nothing of
value. Note that when you reply to a Proven Liar you encourage them
to continue lying.

Raymond C. Fischer (54)
(Louise Fischer)
90 Hunt Way
Campbell, CA 95008
408-374-1969

[][][][][][]
The DemocRAT Hall Of Shame http://www.democrathallof... asks
"Why do you always LIE?"

[Courtesy of Buster Norris]

On 05 Sep 2011 00:09:23 GMT, rfischer@sonic.net (Ray Fischer) wrote:
>The GOP wants to raise taxes for middle-class
>workers, according to their definition of "raise taxes".

LIAR!!!!!!!!!!!!!!!!!!!

"When discussing the concept that all potential solutions ought to ?be
on the table? or that he ?won?t rule anything in our out,? he has
always emphasized that any potential solution must be looked at
through the prism of jobs and whether those proposed solutions would
strengthen the economy. Obviously, tax increases wouldn?t make that
list." Ways and Means Committee spokesperson for Ways and Means
Committee chairman Rep. Dave Camp (R-Mich.).
http://thehill.com/blogs/blog-briefing-room/news/176511-gop-spokesman-camps-position-on-tax-hikes-has-n...

Posted from:
The DemocRATs Hall of Shame!
http://www.democrathallof...

*US*

3/17/2012 10:56:00 AM

0

On Fri, 16 Mar 2012 17:24:32 -0500, Robert Fitzgerald <robert@fizmarkianbobo.com> wrote:

>On Fri, 16 Mar 2012 08:00:08 -0400, * US * wrote:
>> On Fri, 16 Mar 2012 05:41:57 -0400, NoThought <NoThought@nowhere.com> wrote:
>>>Proof?
>>
>> Why didn't you respond with that to the lie about WMD in Iraq?
>>
>>>Thought not.
>>
>> Of course you didn't.
>
>Saddam ...

Bush and Cheney knew they were lying about the WMD.

*US*

3/17/2012 10:56:00 AM

0

On 17 Mar 2012 01:53:50 GMT, rfischer@sonic.net (Ray Fischer) wrote:

> <Americans@USA.now> wrote:
>>On Fri, 16 Mar 2012 05:41:57 -0400, NoThought <NoThought@nowhere.com> wrote:
>>>Proof?
>>
>>Why didn't you respond with that to the
>>lie about WMD in Iraq?
>>
>>>Thought not.
>>
>>Of course you didn't.
>
>Morons like him still believe that if he gives rich people more of
>his money then they'll eventually give him some money too.

He probably can't help it. Perhaps he has pellagra.