osdir.com
mailing list archive

Subject: Re: Emulating a web browser - msg#02879

List: ruby-talk

Date: Prev Next Index Thread: Prev Next Index
On Thu, 2009-04-30 at 16:54 +0900, Adam Bender wrote:
> I am looking for a library to help me emulate a web browser, at least at the
> network level. By this I mean I would like to run a program that, from the
> point of view of a web server, behaves just like, say, Firefox, but I don't
> care about actually displaying text or images or anything like that. What I
> would like it to do is speak HTTP, store and send cookies, automatically
> fetch embedded content like images and style sheets, and so forth. I
> thought Mechanize was what I wanted, but it doesn't fetch embedded content.
> It doesn't even recognize it. I could perhaps tell Nokogiri to find all the
> images and have Mechanize fetch them, but I've never used Nokogiri before, I
> don't know an exhaustive list of types of embedded content Firefox loads
> automatically (images, JavaScript, Flash, anything else?), and it seems like
> getting Mechanize to emulate FF's HTTP request for these objects is
> difficult.
>
> Are there libraries that are meant for this type of interaction with
> websites? Perhaps I'm better off abandoning Ruby and making a Firefox
> extension.

I'm not sure what you want to do, but have you looked at Watir?
http://wtr.rubyforge.org/

> Thanks,
>
> Adam
--
Vikhyat Korrapati
http://aetus.net/


Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: Defining a default proc for Hash

2009/4/30 Srijayanth Sridhar <srijayanth@xxxxxxxxx>: > Yes, I did. All that tells me is that it isn't possible to set a default > proc using default or any other calls. Which is why I asked, if there is any > *other* way to do it. If not, it simply can't be done. Of course, it would > also be nice if someone could explain the rationale for not wanting to alter > the default proc once it has been defined. > You can do it like this: class Hash def default_proc=(blk) self.replace(Hash.new(&blk).merge(self)) end end h = {1=>2,3=>4} p h.default_proc h.default_proc = proc {|h,k| h[k]=3 } p h.default_proc Regards, Park Heesob

Next Message by Date: click to view message preview

Re: Random Access using IO#pos in code blocks

2009/4/30 Brian Candler <b.candler@xxxxxxxxx>: > Robert Klemme wrote: >> String#scan is likely faster than manually matching portions with >> #match.  In both versions of Ruby you can do this to get the >> /character/ offset: >> >> irb(main):001:0> s=%{foo bar baz} >> => "foo bar baz" >> irb(main):002:0> s.scan(/\w+/) { p $`.length } >> 0 >> 4 >> 8 >> => "foo bar baz" > > Well, my guess is that would be *less* efficient for large paragraphs, > since $` forces allocation of a new string containing all the text from > the start to the current point. Last time I checked the actual string buffer was shared so the overhead is just a single instance. I do have to admit though that I do not know when the object is allocated (i.e. at time of match or when referencing $`). > But that reminds me, there is a global > variable containing a MatchData object: $~ > > So you can write: > > irb(main):001:0> s=%{foo bar baz} > => "foo bar baz" > irb(main):002:0> s.scan(/\w+/) { p $~.begin(0) } > 0 > 4 > 8 > => "foo bar baz" Also a good variant! (Btw, MatchData might be even more heavyweight than a sub string.) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/

Previous Message by Thread: click to view message preview

Emulating a web browser

I am looking for a library to help me emulate a web browser, at least at the network level. By this I mean I would like to run a program that, from the point of view of a web server, behaves just like, say, Firefox, but I don't care about actually displaying text or images or anything like that. What I would like it to do is speak HTTP, store and send cookies, automatically fetch embedded content like images and style sheets, and so forth. I thought Mechanize was what I wanted, but it doesn't fetch embedded content. It doesn't even recognize it. I could perhaps tell Nokogiri to find all the images and have Mechanize fetch them, but I've never used Nokogiri before, I don't know an exhaustive list of types of embedded content Firefox loads automatically (images, JavaScript, Flash, anything else?), and it seems like getting Mechanize to emulate FF's HTTP request for these objects is difficult. Are there libraries that are meant for this type of interaction with websites? Perhaps I'm better off abandoning Ruby and making a Firefox extension. Thanks, Adam

Next Message by Thread: click to view message preview

Re: Emulating a web browser

On Thu, 2009-04-30 at 16:54 +0900, Adam Bender wrote: > > I am looking for a library to help me emulate a web browser, at least at > the > > network level. By this I mean I would like to run a program that, from > the > > point of view of a web server, behaves just like, say, Firefox, but I > don't > > care about actually displaying text or images or anything like that. > What I > > would like it to do is speak HTTP, store and send cookies, automatically > > fetch embedded content like images and style sheets, and so forth. Take a look at Celerity. http://celerity.rubyforge.org/ Bret -- Bret Pettichord CTO, WatirCraft LLC, www.watircraft.com Lead Developer, Watir, www.watir.com Blog, www.io.com/~wazmo/blog Twitter, www.twitter.com/bpettichord GTalk: bpettichord@xxxxxxxxx Ask Me About Watir Training www.watircraft.com/training
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by