cannot I search the doc's contents (doc=file.read) one more times?

Discussion in 'Ruby' started by shaobo.li@gmail.com, Jan 11, 2005.

  1. Guest

    Hi,
    I wanna retrive ip and its port from the html file which contains
    "<tr bgcolor=#e3e6ea><td>61.135.158.111</td>
    <td>80</td>",cannot I search the doc's contents (doc=file.read) one
    more times?

    doc=file.read

    #first get ip'es success
    ips=doc.scan(/(\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3})/)
    ips.each {|ip| puts ip }

    #then get ports still on doc ,but no one got nothing,if commentted
    above ip scans ,this would works.
    ports=doc.scan(/<td>(\d+)<\/td>/)
    ports.each {|port| puts port }

    file.close

    Thanks in advance!
     
    , Jan 11, 2005
    #1
    1. Advertisements

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. Alex Smith
    Replies:
    2
    Views:
    547
    Alex Smith
    Jun 10, 2005
  2. Matt
    Replies:
    3
    Views:
    748
    Tor Iver Wilhelmsen
    Sep 17, 2004
  3. sachin
    Replies:
    1
    Views:
    486
    Tjerk Wolterink
    Dec 1, 2005
  4. Replies:
    4
    Views:
    438
    Jerry Coffin
    Jul 28, 2006
  5. Merciadri Luca
    Replies:
    4
    Views:
    1,048
  6. Abby Lee
    Replies:
    5
    Views:
    695
    Abby Lee
    Aug 2, 2004
  7. Asif Iqbal
    Replies:
    0
    Views:
    251
    Asif Iqbal
    Aug 6, 2009
  8. Replies:
    3
    Views:
    259
    Gary Herron
    Dec 23, 2013
Loading...