A
anne001
I am trying to run the ruby lynux tutorial on web spiders
http://www.linux-magazine.com/issue/51/Ruby_Web_Spiders.pdf
Apparently, the information has moved on the livejournal.com. The
tutorial says
"you can get a wealth of information from the http response object
returned by the
net http get function"
If I use puts data, I get
The document has moved <A
HREF="http://anne.livejournal.com/profile">here</A>.<P
if I use puts resp, I get
`puts': stack level too deep (SystemStackError)
Is the tutorial refering to the data part of the response only?
Here is a cgi script on livejournal
#!/usr/bin/perl
use LWP::Simple;
print "Content-type: text/html\n\n";
print get('http://www.livejournal.com/customview.cgi' .
'?username=username&styleid=101');
http://www.livejournal.com/developer/embedding.bml?method=cgi
Here is the program I am working with
-------------------------------------------------------->
require 'net/http'
h=Net::HTTP.new('www.livejournal.com', 80)
friend_arr = []
person= ARGV[0]
resp, data =
h.get("http://www.livejournal.com/userinfo.bml?user=#{person}",nil)
print "Friend list for #{person}\n"
#puts resp
puts data
data.split("\n").each do |line|
line.split(",").each do |token|
if token =~ /userinfo.bml\?user=([^'&]*)\'/
friend_arr.push #1
print #$1\n"
end
end
end
print "\n"
friend_arr.each do |friend|
print "Parsing #{friend}'s. journal for #{person}'s. comments...\n";
f=File.new("#{person}_#{friend}.txt","w")
f.puts 'ruby parse_journal.rb #{friend}#{person}'
f.close
end
http://www.linux-magazine.com/issue/51/Ruby_Web_Spiders.pdf
Apparently, the information has moved on the livejournal.com. The
tutorial says
"you can get a wealth of information from the http response object
returned by the
net http get function"
If I use puts data, I get
The document has moved <A
HREF="http://anne.livejournal.com/profile">here</A>.<P
if I use puts resp, I get
`puts': stack level too deep (SystemStackError)
Is the tutorial refering to the data part of the response only?
Here is a cgi script on livejournal
#!/usr/bin/perl
use LWP::Simple;
print "Content-type: text/html\n\n";
print get('http://www.livejournal.com/customview.cgi' .
'?username=username&styleid=101');
http://www.livejournal.com/developer/embedding.bml?method=cgi
Here is the program I am working with
-------------------------------------------------------->
require 'net/http'
h=Net::HTTP.new('www.livejournal.com', 80)
friend_arr = []
person= ARGV[0]
resp, data =
h.get("http://www.livejournal.com/userinfo.bml?user=#{person}",nil)
print "Friend list for #{person}\n"
#puts resp
puts data
data.split("\n").each do |line|
line.split(",").each do |token|
if token =~ /userinfo.bml\?user=([^'&]*)\'/
friend_arr.push #1
print #$1\n"
end
end
end
print "\n"
friend_arr.each do |friend|
print "Parsing #{friend}'s. journal for #{person}'s. comments...\n";
f=File.new("#{person}_#{friend}.txt","w")
f.puts 'ruby parse_journal.rb #{friend}#{person}'
f.close
end