Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Wednesday, November 29, 2006

Code for Extracting Html Content of specific Website

Code for Extracting Html Content of specific Website

Below code is used to extract the html content of specific site.

try this by just copy and paste the below code.

require 'open-uri'
require 'pp'

open('http://www.chennairails.blogspot.com') do |a|
# hash with meta information
pp a.meta

#
pp "Content-Type: " + a.content_type # meta content type
pp "last modified" + a.last_modified.to_s

no = 1
# print the first thousands lines
a.each do |line|
print "#{no}: #{line}"
no += 1
break if no > 1000 #no of lines
end
end

source: code snippets

Enjoy rails!

Monday, November 27, 2006

open links in new,current,background, window, in Java script.


how to open links in current window, new window, background.

use this java script code:



function
open2(url, opt){
if (opt == 0) // current window
window.location = url;
else if (opt == 1)
// new window
window.open(url);
else if (opt == 2) // background window
{window.open(url); self.focus();}
}


ok bye..

Pay Pal

Sign up for PayPal and start accepting credit card payments instantly.

Ruby Corner

Earn Money