Ruby

Ruby – Scrap the content from HTML Source

CODE.rb

code='<html>
<head>
<title>title</title>
<meta content=”title” name=”keywords”/>
<meta content=”text/html; charset=iso-8859-1″ http-equiv=”Content-
Type”/>’

puts content= code.scan(%r{content=”(.*?)”}im).flatten[0].to_s
puts name=code.scan(%r{name=”(.*?)”}im).flatten.to_s

 

Output:

title
keywords

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s