From: Tom Bombadil Date: 2007-06-11T21:44:15+09:00 Subject: Re: Problem with getting info from several websites ------=_Part_104166_28014661.1181565856071 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Indeed, I appreciate!! I have actually 2 more questions regarding this topic. Thus, 1) I'd like to either create a .txt or .xml file for each id. Can I go ahead and use aFile = File.new("bid.txt", "w") and aFile.close? 2) How can I chomp the \n and \t characters in the terminal output? I only need the text w/o tags. Best on separate lines... I owe you a pitcher :-) # gets the content of the div id ="vulnerability", either as text or html p (doc/'#vulnerability').inner_text.strip end # create a new file aFile = File.new("bid.txt", "w") #... code to process the file # close the file aFile.close # prints div id = 'vulnerability' puts p -- On 6/10/07, George Malamidis wrote: > > Hello, > > Does this work for you? > > %w(rubygems hpricot open-uri).each { |e| require e } > > (1..10).each do |id| > doc = Hpricot(open("http://www.securityfocus.com/bid/#{id}")) > p (doc/'#vulnerability').inner_html > end > > George > > On 10 Jun 2007, at 10:26, Tom Bombadil wrote: > > > Hi there, > > > > I'm trying to get data from a couple of websites at the same time > > by using: > > > > (1..10).each { |p| print p} # should get the content from the > > pages with > > the id's 1 to 10... > > > > # load the Securityfocus home page (id 1 to start) > > doc = Hpricot(open("http://www.securityfocus.com/bid/1 > www.securityfocus.com/bid/715> > > ")) > > > > # get the content of the div id ="vulnerability" > > p =(doc/'#vulnerability').inner_html > > > > # prints div id = 'vulnerability' > > puts p > > > > Must I use an array? > > > > Thanks, > > Tom > > > ------=_Part_104166_28014661.1181565856071--