39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/ted_talk.rb', line 39
def self.(lang, num = 12)
if lang != "en"
html = DownloadUtils.get_html("http://www.ted.com/translate/languages/#{lang}", true)
html_doc = Nokogiri::HTML(html)
puts "--------------------------------------------------"
html_doc.xpath("//div[@id='list']//dd//a[1]").each do |link|
puts link.attribute("title")
puts link.attribute("href").text.sub(/\A\//, "http://www.ted.com/")
puts "--------------------------------------------------"
end
else
= DownloadUtils.get_html("http://feeds.feedburner.com/tedtalks_video", true)
= Nokogiri::XML()
talks = .xpath("//item")
puts "--------------------------------------------------"
talks.each_with_index do |talk, index|
puts title = talk.xpath("title").text
puts pubdate = talk.xpath("pubDate").text
puts category = talk.xpath("category").text
puts source_url = talk.xpath("feedburner:origLink").text
puts description = talk.xpath("description").text
puts "--------------------------------------------------"
break if index + 1 == num
end
end
end
|