DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone >

Tamilbeat.com Mp3 Crawler

Snippets Manager user avatar by
Snippets Manager
·
Mar. 14, 07 · · Code Snippet
Like (0)
Save
Tweet
3.04K Views

Join the DZone community and get the full member experience.

Join For Free
create a file called links.dat and put the songs link from tamilbeat.com


#!/usr/bin/env ruby
require 'net/http'
require 'socket'
                                                                                                                            
Thread.abort_on_exception = true
threads = []
                                                                                                                            
line = File.open("links.dat")
IO.foreach("links.dat") {|line|
  if %r{http://([^/]+)/([^/]+/+.+)}i =~ line
    domain,path = $1, $2
  end
  web = TCPSocket.new(domain,"http")
  web.print "GET /"+path+" HTTP/1.0\n\n"
  web.print "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070220 Firefox/2.0.0.2"
  answer = web.gets(nil)
  web.close
                                                                                                                            
  # for mp3
  arr = answer.scan(/http:\/\/www.+mp3/)
                                                                                                                            
  arr.each do |e|
    threads << Thread.new(e){|mp3|
      if %r{http://([^/]+)/([^/]+/+.+)/(.+mp3)}i =~ mp3
        website,song,name = $1, $2, $3
      end
      a=Net::HTTP.new(website,80)
      song_get = "/"+song+"/"+name
      puts "Fetching #{website}#{song_get}"
      resp, data = a.get(song_get,nil)
      puts "Got #{website}#{song_get}: #{resp.message}"
      open(name,'w'){|f| f.write(data)}
    }
  end
}
threads.each {|aThread| aThread.join}

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How to Generate Fake Test Data
  • Composable Architecture
  • Ultra-Fast Microservices: When Microstream Meets Wildfly
  • Java Hashtable, HashMap, ConcurrentHashMap: Performance Impact

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo