From: "G.Durga Prasad" Date: 2008-10-17T22:52:12+09:00 Subject: Re: Shoes GUI - downloading site, using reg exs on body ------=_Part_122998_14704792.1224251566499 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Did you go through the file samples/simple-downloader.rb in the source of the shoes Prasad On Thu, Oct 16, 2008 at 11:35 PM, Double Minus wrote: > So I want my app to download the text of a site's body (easy) and then I > want to use regular expressions to pick out chunks of text. > > In my very limited skills/knowledge, I've had a hard time getting this > working. I've tried two approaches... > > > Code: > > Shoes.app do > > stack :left => 65, :top => 75 do > @results = para "results" > end > > stack (:left => 165, :top => 180) do > para "URL:" > flow do > button "Clear" do > @status.replace "results cleared..." and > @searching.replace " " and > @results.replace "results" > end > @url = edit_line "http://www.google.com/" > button "OK" do > > stack do > @searching = title "Searching site", :size => 16 > @status = para "One moment..." > download @url.text do |site| > @status.text = "Body: " + site.response.body.inspect > regex = Regexp.new(/http/) > matchdata = @status.text > if matchdata > @results.text = matchdata[1] > else > @results.text = "NO MATCH" > end > end > end > end > end > end > end > > > That doesn't work. > > This is the other approach: > @status.text = "Body: " + site.response.body.inspect > if @status.text =~ /html/ then > @results.text = $1 > > Any advice/guidance? Am I even on the right track? > > double > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_122998_14704792.1224251566499--