This page must use the Rübÿ Spëëd Mëtäl Cödïng template!!!111

This commit is contained in:
AstRobot 2007-04-11 20:26:41 +00:00
parent a8f7ef9a76
commit cf9569ad36
1 changed files with 4 additions and 6 deletions

View File

@ -1,23 +1,19 @@
==Suchen & Saugen==
<pre>require 'ubygems'
require 'mechanize'
if ARGV.size < 1
puts "Usage: #{$0} [ keywords ... ]"
exit -1
end
agent = WWW::Mechanize.new
homepage = agent.get('http://www.youtube.com/')
searchform = homepage.forms.select { |f| f.action == '/results' }.first
searchform['search_query'] = ARGV.join(' ')
result = searchform.submit
result.root.traverse_element('td') do |td|
if td.classes == ['vinfo']
a = td.find_element('a') || raise
puts a.children.to_s
watch = agent.click(a)
if watch.root.to_s =~ /\?video_id=(.+?)\&l=(.+?)\&t=(.+?)\&/
video_id, l, t = $1, $2, $3
@ -30,6 +26,8 @@ result.root.traverse_element('td') do |td|
end
end
end</pre>
[[Kategorie:Ruby]]
{{Rübÿ Spëëd Mëtäl Cödïng}}