Bit of Fun

L

Lyndon Samson

------=_Part_34850_12204166.1128999252813
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Bit of fun learning FXRuby. This will download and display the thumbnail
images from news.google.com <http://news.google.com/> in a grid
Interesting google are not producing XHTML, their img src's are not quote
delimitered.
---cut/here---
require 'net/http'
require 'rubygems'
require_gem 'fxruby'

include Fox

host =3D "news.google.com <http://news.google.com/>"
loc =3D
"/news?sourceid=3Dnavclient&ie=3DUTF-8&rls=3DGGLD,GGLD:2005-18,GGLD:en&tab=
=3Din&ned=3Dus"
phost =3D "your-proxy"
pport =3D 8080
puser =3D "your-uid"
ppwd =3D "your-pwd"
app =3D FXApp.new
win =3D FXMainWindow.new(app, "news.google.com <http://news.google.com/> -
Image Collection",nil, nil, DECOR_ALL, 100, 100, 800, 600)
matrix =3D FXMatrix.new(win, 7,MATRIX_BY_COLUMNS|FRAME_RAISED)

x =3D 0
y =3D 0
w =3D 100
h =3D 100

Net::HTTP::proxy(phost, pport, puser, ppwd).start(host) {|http|
jpgs =3D http.get(loc).body.to_s.scan(/src=3Dhttp:\/\/.*?(\/.*?jpg) /)

jpgs.each {|pic|
puts "Loading #{pic[0]}"
jpgdata =3D http.get(pic[0]).body

img =3D FXJPGImage.new(app, jpgdata, IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)

x +=3D 150
imageview =3D FXImageView.new(matrix, img, nil, 0,
LAYOUT_FILL_ROW|LAYOUT_EXPLICIT, x, y ,w ,h)
}
}

app.create
win.show
app.run
---cut/here---
 
J

JB Eriksson

------=_Part_7552_13401695.1129027681828
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

cool beans. couldn't get it to work first,so I edited out the proxy bit:

require 'net/http'
require 'rubygems'
require_gem 'fxruby'

include Fox

host =3D "news.google.com <http://news.google.com>"
loc =3D
"/news?sourceid=3Dnavclient&ie=3DUTF-8&rls=3DGGLD,GGLD:2005-18,GGLD:en&tab=
=3Din&ned=3Dus"

app =3D FXApp.new
win =3D FXMainWindow.new(app, "news.google.com <http://news.google.com> <
http://news.google.com/>-Image Collection",nil, nil, DECOR_ALL, 100, 100,
800, 600)
matrix =3D FXMatrix.new(win, 5,MATRIX_BY_COLUMNS|FRAME_RAISED)

x =3D 0
y =3D 0
w =3D 100
h =3D 100

Net::HTTP.start(host) {|http|
jpgs =3D http.get(loc).body.to_s.scan(/src=3Dhttp:\/\/.*?(\/.*?jpg) /)

jpgs.each {|pic|
puts "Loading #{pic[0]}"
jpgdata =3D http.get(pic[0]).body

img =3D FXJPGImage.new(app, jpgdata, IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)

x +=3D 150
imageview =3D FXImageView.new(matrix, img, nil, 0,
LAYOUT_FILL_ROW|LAYOUT_EXPLICIT, x, y ,w ,h)
}
}

app.create
win.show
app.run


Bit of fun learning FXRuby. This will download and display the thumbnail
images from news.google.com <http://news.google.com> <
http://news.google.com/> in a grid
Interesting google are not producing XHTML, their img src's are not quote
delimitered.
---cut/here---
require 'net/http'
require 'rubygems'
require_gem 'fxruby'

include Fox

host =3D "news.google.com <http://news.google.com> <http://news.google.co= m/
loc =3D

"/news?sourceid=3Dnavclient&ie=3DUTF-8&rls=3DGGLD,GGLD:2005-18,GGLD:en&ta= b=3Din&ned=3Dus"
phost =3D "your-proxy"
pport =3D 8080
puser =3D "your-uid"
ppwd =3D "your-pwd"
app =3D FXApp.new
win =3D FXMainWindow.new(app, "news.google.com <http://news.google.com> <
http://news.google.com/> -
Image Collection",nil, nil, DECOR_ALL, 100, 100, 800, 600)
matrix =3D FXMatrix.new(win, 7,MATRIX_BY_COLUMNS|FRAME_RAISED)

x =3D 0
y =3D 0
w =3D 100
h =3D 100

Net::HTTP::proxy(phost, pport, puser, ppwd).start(host) {|http|
jpgs =3D http.get(loc).body.to_s.scan(/src=3Dhttp:\/\/.*?(\/.*?jpg) /)

jpgs.each {|pic|
puts "Loading #{pic[0]}"
jpgdata =3D http.get(pic[0]).body

img =3D FXJPGImage.new(app, jpgdata, IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)

x +=3D 150
imageview =3D FXImageView.new(matrix, img, nil, 0,
LAYOUT_FILL_ROW|LAYOUT_EXPLICIT, x, y ,w ,h)
}
}

app.create
win.show
app.run
---cut/here---

------=_Part_7552_13401695.1129027681828--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top