A search spider i…
来源:互联网 发布:千牛mac历史版本 编辑:程序博客网 时间:2024/06/07 10:07
转自http://blog.dharanasoft.com/2012/03/19/a-search-spider-in-ruby-using-capybara-webkit/
Posted: March19, 2012 | Author: DeepakPrasanna | Filedunder: Uncategorized |Leave acomment
When I first looked at
require 'ruby gems'
require 'capybara'
require 'capybara/dsl'
require 'capybara-webkit'
Capybara.run_server = false
Capybara.current_driver = :webkit
Capybara.app_host = "http://www.google.com/"
module Spider
class Google
include Capybara::DSL
def search
visit('/')
fill_in "q", :with => ARGV[0] || "I love Ruby!"
click_button "Google Search"
all("li.g h3").each do |h3|
a = h3.find("a")
puts "#{h3.text} => #{a[:href]}"
end
end
end
end
spider = Spider::Google.new
spider.search
0 0
- A search spider i…
- POJ 1005 I Think I Need a Houseb…
- tomorrow I will have a trip to W…
- Programming a Spider&n…
- poj 3468 A Simple Problem with I…
- poj 3468 A Simple Problem with I…
- poj 3468 A Simple Problem with I…
- A new I/O memory access mechanis…
- A new I/O memory access mechanis…
- 【原创】python spider …
- 【原创】Python Spider …
- #define A (* (volatile unsigned …
- HDOJ 1017 A Mathematical Cur…
- HDOJ 4245 A Famous Music Comp…
- How do I get default date and ti…
- Check a loop in a list with line…
- How to pass a hash to a subrouti…
- Writing a Simple …
- 大牛初步之kettle连接mysql的奇葩错误: message from server: "Host 'PCXX‘ is not allowed to connect to this MySQL s
- C# MySql 数据数据备份与还原
- iOS开发-为界面插入背景图片(整理…
- 如何快速正确的安装 Ruby,&nb…
- 在Mac上安装Ruby on Rails
- A search spider i…
- 在MAC中安装Compass的方法
- Ruby学习一些有用的文章
- Ruby Sqlite学习心得
- PHP用户注册邮箱验证激活帐号
- excel中插入行后能自动插入上一行…
- iOS 蓝牙定位 iBeacons
- IOS开发-使用蓝牙(CoreBluetooth.f…
- 下载Linux ubuntu操作系统IS…