Revisions
-
Justin Mazzi revised this gist
May 25, 2011 . 1 changed file with 10 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,14 @@ require 'mechanize' @username = 'user@domain.com' @password = 'hi2u' @download_path = File.expand_path 'downloads' @wget_cookie = File.expand_path(File.dirname(__FILE__)) + '/wget-cookies.txt' unless File.directory? @download_path puts "@{download_path} doesn't exist!" exit end agent = Mechanize.new agent.cookie_jar.load('cookies.yml') if File.exists?('cookies.yml') @@ -31,7 +34,7 @@ def wget(path) system cmd end system "cd #{@download_path}; wget --load-cookies #{@wget_cookie} --continue '#{path}'" end page = agent.get 'https://peepcode.com/products' @@ -43,8 +46,9 @@ def wget(path) download_links = result.links_with(:href => %r{/unlimited_downloads/}).each do |dl| ogg = dl.href.match(/\.ogg/) s3 = (dl.text.match(/USA-West/) || dl.href.match(/s3=true/)) wmv = dl.href.match(/wmv_zip/) if !s3 && !ogg && !links.include?(dl.href) && !wmv links.push dl.href wget dl.href end -
Justin Mazzi revised this gist
May 24, 2011 . No changes.There are no files selected for viewing
-
Justin Mazzi revised this gist
May 24, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,7 @@ def wget(path) system cmd end system "cd #{@download_path}; wget --load-cookies ../wget-cookies.txt -c '#{path}'" end page = agent.get 'https://peepcode.com/products' -
Justin Mazzi revised this gist
May 24, 2011 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,8 @@ require 'mechanize' # Downloads everything from the East location. # Skips all .ogg files (I don't use them) @username = 'user@domain.com' @password = 'hi2u' @download_path = '/Users/username/peepcode/downloads' -
Justin Mazzi revised this gist
May 24, 2011 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -38,7 +38,10 @@ def wget(path) result = agent.click link links = [] download_links = result.links_with(:href => %r{/unlimited_downloads/}).each do |dl| ogg = dl.href.match(/\.ogg/) s3 = (dl.text.match(/USA-West/) || dl.href.match(/s3=true/)) if !s3 && !ogg && !links.include?(dl.href) links.push dl.href wget dl.href end -
Justin Mazzi revised this gist
May 24, 2011 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,9 @@ def wget(path) unless File.exists?('wget-cookies.txt') cmd = "wget --no-check-certificate --keep-session-cookies --save-cookies wget-cookies.txt " cmd<< "--post-data 'email=#{@username}&password=#{@password}' https://peepcode.com/sessions" system cmd end system "cd #{@download_path}; wget --load-cookies ../wget-cookies.txt '#{path}'" -
Justin Mazzi created this gist
May 24, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ require 'mechanize' @username = 'user@domain.com' @password = 'hi2u' @download_path = '/Users/username/peepcode/downloads' agent = Mechanize.new agent.cookie_jar.load('cookies.yml') if File.exists?('cookies.yml') page = agent.get 'https://peepcode.com/' unless page.body.match /\/peepers\/account\/edit/ puts "Logging in" page = agent.get 'https://peepcode.com/login' signin_form = page.form_with(:action => '/sessions') signin_form.email = @username signin_form.password = @password agent.submit(signin_form, signin_form.buttons.first) agent.cookie_jar.save_as('cookies.yml') end def wget(path) unless File.exists?('wget-cookies.txt') system "wget --no-check-certificate --keep-session-cookies --save-cookies wget-cookies.txt --post-data 'email=#{@username}&password=#{@password}' https://peepcode.com/sessions" end system "cd #{@download_path}; wget --load-cookies ../wget-cookies.txt '#{path}'" end page = agent.get 'https://peepcode.com/products' page.links_with(:href => %r{/products/}).each do |link| puts "Processing #{link.text}" result = agent.click link links = [] download_links = result.links_with(:href => %r{/unlimited_downloads/}).each do |dl| if !dl.text.match(/USA-West/) && !dl.href.match(/\.ogg/) && !dl.href.match(/s3=true/) && !links.include?(dl.href) links.push dl.href wget dl.href end end puts end