Changed (Δ704 bytes):

raw changeset »

03/zebo.rb (29 lines added, 0 lines removed)

Up to file-list 03/zebo.rb:

1
#!/opt/local/bin/ruby
2
3
require 'rubygems'
4
require 'kconv'
5
require 'open-uri'
6
require 'hpricot'
7
8
9
class Zebo
10
  
11
  # キーワード検索して商品詳細ページのURLリストを返す
12
  def wishpages(search='car', maxPage=4)
13
    urlList = Array.new
14
    for page in 1..maxPage # 10ページ
15
      puts 'processing page:' + page.to_s
16
      url = 'http://member.zebo.com/Main?event_key=USERSEARCH&action=ns&keyword='+search+'&tab=review&rPage='+page.to_s
17
      page = open(url).read().toutf8
18
      doc = Hpricot(page)
19
      links = doc/:a
20
      links.each{ |link|
21
        urlList.push(link[:href]) if link[:href] =~ /http:\/\/reviews.zebo.com\/.*/
22
      }
23
    end
24
    return urlList.uniq
25
  end
26
  
27
end
28
29