Created
May 6, 2013 15:35
-
-
Save yswallow/5525890 to your computer and use it in GitHub Desktop.
vcard.ameba.jp の手に入れた音声を全てダウンロードするスクリプト(誰得
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "nokogiri" | |
| require "./collection-post" | |
| require 'open-uri' | |
| ua = "Mozilla/5.0 (Linux; U; Android 4.0.3; ja-jp; URBANO PROGRESSO Build/010.0.3000) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30" | |
| cookies = { "gameAuthId" => "Your own gameAuthId", "vcardPixelRatio" => "1" } | |
| cookie_str = cookies.map { |cookie| cookie.join('=') }.join(';') | |
| $header = { "Cookie" => cookie_str, "User-Agent" => ua } | |
| def vcard_getio( url ) | |
| unless /^http/ =~ url | |
| url = URI.join("http://vcard.ameba.jp/mypage",url).to_s | |
| end | |
| io = open(url,$header) | |
| end | |
| def collection_post(option = "") | |
| url = "http://vcard.ameba.jp/collection" | |
| uri = URI.parse(url) | |
| data = "status=0&rare=0&voice=2&grade=0&club=0&birthDay=0&blood=0&hight=0&weight=0&bust=0&waist=0&hip=0&star=0&actor=0&sphere=ALL" +option | |
| io = Net::HTTP.new(uri.host) | |
| res = io.post(uri.path,data,$header) | |
| return res.body | |
| end | |
| pages = 1..33 | |
| pages.each do |page| | |
| noko = Nokogiri::HTML(collection_post("&page=#{page}")) | |
| as = noko.xpath('//section[@id="girlsList"]/ul/li/a') | |
| as.each do |a_obj| | |
| girl_link = a_obj["href"] | |
| /(\d+)/ =~ girl_link | |
| puts $1 | |
| girl_id = $1 | |
| dir_path = "./voice/#{$1}" | |
| Dir.mkdir(dir_path) unless FileTest.exist?(dir_path) | |
| io = vcard_getio(girl_link) | |
| voice_link_objs = Nokogiri::HTML(io).xpath('//div[@id="voiceBox"]/ul/li[@class="voiceBtn voicePlayBtn"]/input[@name="voiceSource"]') | |
| voice_link_objs.each_with_index do |obj,i| | |
| filename = "voice#{i}.mp3" | |
| file_path = dir_path + "/" + filename | |
| voice_link = obj["value"] | |
| voice_io = vcard_getio(voice_link) | |
| File.write file_path,voice_io.read | |
| voice_io.close | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment