Jump to content

[Ruby] Item Icon Grabber


xTurinx

Recommended Posts

I know this is no web application but it is hopefully very usefull for people who wants to implement item icons with relation to their item entry in a web application project.

 

Requirements:

- ruby

- bash/sh

- wget

#!/usr/bin/ruby

require 'net/http'

for i in 1..150000
    url = URI.parse("http://wowhead.com/item=#{i}")
    req = Net::HTTP::Get.new(url.to_s)
    res = Net::HTTP.start(url.host, url.port) {|http|
      http.request(req)
    }

    line = res.body.split("n")

    for itr in 0..line.length
        if line[itr] != nil && line[itr] != '' && line[itr]["image_src"]
            part = line[itr].split(';')
            img = part[part.length - 1].split('"')[0]
            puts "Item: #{i} - Icon: #{img}"
            `cd icons && wget http://wow.zamimg.com/images/wow/icons/large/#{img}`
            `echo "INSERT INTO item_icon (item, icon) VALUES (#{i}, '#{img}')" >> dump.sql`
        end
    end
end

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.