# Ruby (mechanize , net/http)

**URL:** <https://www.ruby-forum.com/t/ruby-mechanize-net-http/171329>\
**Category:** Ruby\
**Created:** [June 30, 2009, 7:39pm UTC](https://www.ruby-forum.com/t/ruby-mechanize-net-http/171329 "2009-06-30T19:39:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![neverhood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/a9a28c/32.png) [@neverhood](https://www.ruby-forum.com/u/neverhood)\
**Post date:** [June 30, 2009, 7:39pm UTC](https://www.ruby-forum.com/t/ruby-mechanize-net-http/171329/1 "2009-06-30T19:39:49Z")

</div>

Hi guys.  
I`m using mechanize to get some images from the web application. I have 2 problems: 1-st : I can`t catch the links. The whole link looks like \<a href =  
"https://…/reports/switch\_accounts.html?.."See full report

And there`re couple of these that i try to catch with a singe regexp

i tried this :  
`
final.links_with(:href => %r{/switch_accounts.html/} ).each do |link|
puts link.href, link.text
end
`

but it doesn`t display anything, but i`m pretty much sure there`re those  
links in the ‘final’ webpage

The second problem - how can i actually save the images to a selected  
folder(assuming i have the links for them)?

Thatnks everybody, any ideas are really appreciated

---

<div class="post-metadata">

**Author:** ![neverhood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/a9a28c/32.png) [@neverhood](https://www.ruby-forum.com/u/neverhood)\
**Post date:** [July 3, 2009, 10:36am UTC](https://www.ruby-forum.com/t/ruby-mechanize-net-http/171329/2 "2009-07-03T10:36:29Z")

</div>

Hello

If you didn’t find it yet:

> > str1 = ‘http://…reports/switch\_accounts.html?..’  
> > =\> “http://…reports/switch\_accounts.html?..”
> 
> > re1 = %r{/switch\_accounts.html/}  
> > =\> //switch\_accounts.html//
> 
> > str1.match re1  
> > =\> nil
> 
> > str2 = ‘http://…reports/switch\_accounts.html/?..’  
> > =\> “http://…reports/switch\_accounts.html/?..”
> 
> > str2.match re1  
> > =\> #MatchData:0xb7e1695c
> 
> > re2 = %r{/switch\_accounts.html?}  
> > =\> //switch\_accounts.html?/
> 
> > str1.match re2  
> > =\> #MatchData:0xb7e0c8d0

I don’t know mechanize, but str2 is an url your regex (re1) would match.  
re2 is the regex that matches your sample url.

Regards, R.
