Screen Scraping an Image

Discussion in 'Ruby' started by Sean Kenney, Dec 3, 2007.

  1. Sean Kenney

    Sean Kenney Guest

    How do you screen scrape an image off of a web page?
     
    Sean Kenney, Dec 3, 2007
    #1
    1. Advertising

  2. Sean Kenney

    Phrogz Guest

    On Dec 3, 2:10 pm, Sean Kenney <> wrote:
    > How do you screen scrape an image off of a web page?


    You find the URL of the image (possibly resolving a relative URL
    against the absolute URL of the page) and then ask the web server to
    send you that file over http.
     
    Phrogz, Dec 3, 2007
    #2
    1. Advertising

  3. Sean Kenney

    Robert Citek Guest

    On Dec 3, 2007 3:24 PM, Phrogz <> wrote:
    > On Dec 3, 2:10 pm, Sean Kenney <> wrote:
    > > How do you screen scrape an image off of a web page?

    >
    > You find the URL of the image (possibly resolving a relative URL
    > against the absolute URL of the page) and then ask the web server to
    > send you that file over http.


    I suspect Sean is asking, what's the ruby way of doing a wget?

    For example:

    wget http://www.ruby-lang.org/images/logo.gif

    Regards,
    - Robert
     
    Robert Citek, Dec 3, 2007
    #3
  4. Sean Kenney

    Sean Kenney Guest

    Sean Kenney, Dec 3, 2007
    #4
  5. Sean Kenney

    Vitor Peres Guest

    Note: parts of this message were removed by the gateway to make it a legal Usenet post.

    On Dec 3, 2007 8:39 PM, Sean Kenney <> wrote:

    > Here's a script I found at
    > http://www.rubynoob.com/articles/2006/8/21/how-to-download-files-with-a-ruby-script
    >
    > require 'net/http'
    >
    > Net::HTTP.start("static.flickr.com") { |http|
    > resp = http.get("/92/218926700_ecedc5fef7_o.jpg")
    > open("fun.jpg", "wb") { |file|
    > file.write(resp.body)
    > }
    > }
    >
    >

    Or maybe shorter:

    require 'open-uri'

    open('image.jpg', 'wb') {|f| f << open('
    http://www.domain.com/image.jpg').read }
     
    Vitor Peres, Dec 5, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Martinez

    Screen Scraping C#

    Robert Martinez, Aug 26, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    2,781
    Robert Martinez
    Aug 26, 2003
  2. George Durzi

    HTML Screen Scraping Q

    George Durzi, Feb 25, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    525
    George Durzi
    Feb 25, 2004
  3. Jim Giblin

    Screen scraping in ASP.NET

    Jim Giblin, Aug 16, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    817
    Jens Christian Mikkelsen
    Aug 16, 2004
  4. niv

    screen scraping question

    niv, Oct 8, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    426
    Scott Allen
    Oct 8, 2004
  5. David Jones

    Web Scraping/Site Scraping

    David Jones, Jul 11, 2004, in forum: Python
    Replies:
    4
    Views:
    529
    Andrew Bennetts
    Jul 13, 2004
Loading...

Share This Page