RailsCasts批量下载地址之Ruby代码

简介:

千呼万唤的Rails3出来了,也该开始学学了,从网上发现一个好的教程http://railscasts.com/episodes,能够下载

image

但遗憾的是每页只显示10个而且无法批量下载,如是发现右边栏有All Episodes链接。

image 

但是这个没有下载地址,只能一个个点进去才能看见下载地址。仔细对比这两个地址

http://railscasts.com/episodes/234-simple-form

http://media.railscasts.com/videos/234_simple_form.mov

发现他们之间有一定的对应关系,狂喜,于是有了如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require 'open-uri'
open( 'http://railscasts.com/episodes/archive' ) do  |f|
   s= ""
   f. each  do  |line|
     s<<line
   end
 
   allUrls= File . new ( File .join( "C:" , "RailCastsVideoURLs.txt" ), "w+" )
   m=/href= "(\/episodes\/.+)" /
   urls= s.scan(m)
   urls. each  { |x|
     begin
      allUrls.puts x[ 0 ].gsub(/\/episodes\//, "http://media.railscasts.com/videos/" ).gsub(/-/, "_" ).to_s+ ".mov"
     end
   }
   allUrls.close
end

 

运行以上代码,可以得到要下载的所有地址,当然前提是你要安装ruby, 如果你没装,那我附上所有的地址吧!找到地址后我相信大家知道怎么下载了,你可以写段Ruby脚本下载,当然我更喜欢用迅雷呀。

http://media.railscasts.com/videos/234_simple_form.mov 
http://media.railscasts.com/videos/233_engage_with_devise.mov 
http://media.railscasts.com/videos/232_routing_walkthrough_part_2.mov 
http://media.railscasts.com/videos/231_routing_walkthrough.mov 
http://media.railscasts.com/videos/230_inherited_resources.mov 
http://media.railscasts.com/videos/229_polling_for_changes.mov 
http://media.railscasts.com/videos/228_sortable_table_columns.mov 
http://media.railscasts.com/videos/227_upgrading_to_rails_3_part_3.mov 
http://media.railscasts.com/videos/226_upgrading_to_rails_3_part_2.mov 
http://media.railscasts.com/videos/225_upgrading_to_rails_3_part_1.mov 
http://media.railscasts.com/videos/224_controllers_in_rails_3.mov 
http://media.railscasts.com/videos/223_charts.mov 
http://media.railscasts.com/videos/222_rack_in_rails_3.mov 
http://media.railscasts.com/videos/221_subdomains_in_rails_3.mov 
http://media.railscasts.com/videos/220_pdfkit.mov 
http://media.railscasts.com/videos/219_active_model.mov 
http://media.railscasts.com/videos/218_making_generators_in_rails_3.mov 
http://media.railscasts.com/videos/217_multistep_forms.mov 
http://media.railscasts.com/videos/216_generators_in_rails_3.mov 
http://media.railscasts.com/videos/215_advanced_queries_in_rails_3.mov 
http://media.railscasts.com/videos/214_a_b_testing_with_a_bingo.mov 
http://media.railscasts.com/videos/213_calendars.mov 
http://media.railscasts.com/videos/212_refactoring_dynamic_delegator.mov 
http://media.railscasts.com/videos/211_validations_in_rails_3.mov 
http://media.railscasts.com/videos/210_customizing_devise.mov 
http://media.railscasts.com/videos/209_introducing_devise.mov 
http://media.railscasts.com/videos/208_erb_blocks_in_rails_3.mov 
http://media.railscasts.com/videos/207_syntax_highlighting.mov 
http://media.railscasts.com/videos/206_action_mailer_in_rails_3.mov 
http://media.railscasts.com/videos/205_unobtrusive_javascript.mov 
http://media.railscasts.com/videos/204_xss_protection_in_rails_3.mov 
http://media.railscasts.com/videos/203_routing_in_rails_3.mov 
http://media.railscasts.com/videos/202_active_record_queries_in_rails_3.mov 
http://media.railscasts.com/videos/201_bundler.mov 
http://media.railscasts.com/videos/200_rails_3_beta_and_rvm.mov 
http://media.railscasts.com/videos/199_mobile_devices.mov 
http://media.railscasts.com/videos/198_edit_multiple_individually.mov 
http://media.railscasts.com/videos/197_nested_model_form_part_2.mov 
http://media.railscasts.com/videos/196_nested_model_form_part_1.mov 
http://media.railscasts.com/videos/195_my_favorite_web_apps_in_2009.mov 
http://media.railscasts.com/videos/194_mongodb_and_mongomapper.mov 
http://media.railscasts.com/videos/193_tableless_model.mov 
http://media.railscasts.com/videos/192_authorization_with_cancan.mov 
http://media.railscasts.com/videos/191_mechanize.mov 
http://media.railscasts.com/videos/190_screen_scraping_with_nokogiri.mov 
http://media.railscasts.com/videos/189_embedded_association.mov 
http://media.railscasts.com/videos/188_declarative_authorization.mov 
http://media.railscasts.com/videos/187_testing_exceptions.mov 
http://media.railscasts.com/videos/186_pickle_with_cucumber.mov 
http://media.railscasts.com/videos/185_formtastic_part_2.mov 
http://media.railscasts.com/videos/184_formtastic_part_1.mov 
http://media.railscasts.com/videos/183_gemcutter_jeweler.mov 
http://media.railscasts.com/videos/182_cropping_images.mov 
http://media.railscasts.com/videos/181_include_vs_joins.mov 
http://media.railscasts.com/videos/180_finding_unused_css.mov 
http://media.railscasts.com/videos/179_seed_data.mov 
http://media.railscasts.com/videos/178_seven_security_tips.mov 
http://media.railscasts.com/videos/177_model_versioning.mov 
http://media.railscasts.com/videos/176_searchlogic.mov 
http://media.railscasts.com/videos/175_ajax_history_and_bookmarks.mov 
http://media.railscasts.com/videos/174_pagination_with_ajax.mov 
http://media.railscasts.com/videos/173_screen_scraping_with_scrapi.mov 
http://media.railscasts.com/videos/172_touch_and_cache.mov 
http://media.railscasts.com/videos/171_delayed_job.mov 
http://media.railscasts.com/videos/170_openid_with_authlogic.mov 
http://media.railscasts.com/videos/169_dynamic_page_caching.mov 
http://media.railscasts.com/videos/168_feed_parsing.mov 
http://media.railscasts.com/videos/167_more_on_virtual_attributes.mov 
http://media.railscasts.com/videos/166_metric_fu.mov 
http://media.railscasts.com/videos/165_edit_multiple.mov 
http://media.railscasts.com/videos/164_cron_in_ruby.mov 
http://media.railscasts.com/videos/163_self_referential_association.mov 
http://media.railscasts.com/videos/162_tree_based_navigation.mov 
http://media.railscasts.com/videos/161_three_profiling_tools.mov 
http://media.railscasts.com/videos/160_authlogic.mov 
http://media.railscasts.com/videos/159_more_on_cucumber.mov 
http://media.railscasts.com/videos/158_factories_not_fixtures.mov 
http://media.railscasts.com/videos/157_rspec_matchers_macros.mov 
http://media.railscasts.com/videos/156_webrat.mov 
http://media.railscasts.com/videos/155_beginning_with_cucumber.mov 
http://media.railscasts.com/videos/154_polymorphic_association.mov 
http://media.railscasts.com/videos/153_pdfs_with_prawn.mov 
http://media.railscasts.com/videos/152_rails_2_3_extras.mov 
http://media.railscasts.com/videos/151_rack_middleware.mov 
http://media.railscasts.com/videos/150_rails_metal.mov 
http://media.railscasts.com/videos/149_rails_engines.mov 
http://media.railscasts.com/videos/148_app_templates_in_rails_2_3.mov 
http://media.railscasts.com/videos/147_sortable_lists.mov 
http://media.railscasts.com/videos/146_paypal_express_checkout.mov 
http://media.railscasts.com/videos/145_integrating_active_merchant.mov 
http://media.railscasts.com/videos/144_active_merchant_basics.mov 
http://media.railscasts.com/videos/143_paypal_security.mov 
http://media.railscasts.com/videos/142_paypal_notifications.mov 
http://media.railscasts.com/videos/141_paypal_basics.mov 
http://media.railscasts.com/videos/140_rails_2_2_extras.mov 
http://media.railscasts.com/videos/139_nested_resources.mov 
http://media.railscasts.com/videos/138_i18n.mov 
http://media.railscasts.com/videos/137_memoization.mov 
http://media.railscasts.com/videos/136_jquery.mov 
http://media.railscasts.com/videos/135_making_a_gem.mov 
http://media.railscasts.com/videos/134_paperclip.mov 
http://media.railscasts.com/videos/133_capistrano_tasks.mov 
http://media.railscasts.com/videos/132_helpers_outside_views.mov 
http://media.railscasts.com/videos/131_going_back.mov 
http://media.railscasts.com/videos/130_monitoring_with_god.mov 
http://media.railscasts.com/videos/129_custom_daemon.mov 
http://media.railscasts.com/videos/128_starling_and_workling.mov 
http://media.railscasts.com/videos/127_rake_in_background.mov 
http://media.railscasts.com/videos/126_populating_a_database.mov 
http://media.railscasts.com/videos/125_dynamic_layouts.mov 
http://media.railscasts.com/videos/124_beta_invitations.mov 
http://media.railscasts.com/videos/123_subdomains.mov 
http://media.railscasts.com/videos/122_passenger_in_development.mov 
http://media.railscasts.com/videos/121_non_active_record_model.mov 
http://media.railscasts.com/videos/120_thinking_sphinx.mov 
http://media.railscasts.com/videos/119_session_based_model.mov 
http://media.railscasts.com/videos/118_liquid.mov 
http://media.railscasts.com/videos/117_semi_static_pages.mov 
http://media.railscasts.com/videos/116_selenium.mov 
http://media.railscasts.com/videos/115_caching_in_rails_2_1.mov 
http://media.railscasts.com/videos/114_endless_page.mov 
http://media.railscasts.com/videos/113_contributing_to_rails_with_git.mov 
http://media.railscasts.com/videos/112_anonymous_scopes.mov 
http://media.railscasts.com/videos/111_advanced_search_form.mov 
http://media.railscasts.com/videos/110_gem_dependencies.mov 
http://media.railscasts.com/videos/109_tracking_attribute_changes.mov 
http://media.railscasts.com/videos/108_named_scope.mov 
http://media.railscasts.com/videos/107_migrations_in_rails_2_1.mov 
http://media.railscasts.com/videos/106_time_zones_in_rails_2_1.mov 
http://media.railscasts.com/videos/105_gitting_rails_2_1_rc1.mov 
http://media.railscasts.com/videos/104_exception_notifications.mov 
http://media.railscasts.com/videos/103_site_wide_announcements.mov 
http://media.railscasts.com/videos/102_auto_complete_association.mov 
http://media.railscasts.com/videos/101_refactoring_out_helper_object.mov 
http://media.railscasts.com/videos/100_5_view_tips.mov 
http://media.railscasts.com/videos/99_complex_partials.mov 
http://media.railscasts.com/videos/98_request_profiling.mov 
http://media.railscasts.com/videos/97_analyzing_the_production_log.mov 
http://media.railscasts.com/videos/96_git_on_rails.mov 
http://media.railscasts.com/videos/95_more_on_activeresource.mov 
http://media.railscasts.com/videos/94_activeresource_basics.mov 
http://media.railscasts.com/videos/93_action_caching.mov 
http://media.railscasts.com/videos/92_make_resourceful.mov 
http://media.railscasts.com/videos/91_refactoring_long_methods.mov 
http://media.railscasts.com/videos/90_fragment_caching.mov 
http://media.railscasts.com/videos/89_page_caching.mov 
http://media.railscasts.com/videos/88_dynamic_select_menus.mov 
http://media.railscasts.com/videos/87_generating_rss_feeds.mov 
http://media.railscasts.com/videos/86_logging_variables.mov 
http://media.railscasts.com/videos/85_yaml_configuration_file.mov 
http://media.railscasts.com/videos/84_cookie_based_session_store.mov 
http://media.railscasts.com/videos/83_migrations_in_rails_2_0.mov 
http://media.railscasts.com/videos/82_http_basic_authentication.mov 
http://media.railscasts.com/videos/81_fixtures_in_rails_2_0.mov 
http://media.railscasts.com/videos/80_simplify_views_with_rails_2_0.mov 
http://media.railscasts.com/videos/79_generate_named_routes.mov 
http://media.railscasts.com/videos/78_generating_pdf_documents.mov 
http://media.railscasts.com/videos/77_destroy_without_javascript.mov 
http://media.railscasts.com/videos/76_scope_out.mov 
http://media.railscasts.com/videos/75_complex_forms_part_3.mov 
http://media.railscasts.com/videos/74_complex_forms_part_2.mov 
http://media.railscasts.com/videos/73_complex_forms_part_1.mov 
http://media.railscasts.com/videos/72_adding_an_environment.mov 
http://media.railscasts.com/videos/71_testing_controllers_with_rspec.mov 
http://media.railscasts.com/videos/70_custom_routes.mov 
http://media.railscasts.com/videos/69_markaby_in_helper.mov 
http://media.railscasts.com/videos/68_openid_authentication.mov 
http://media.railscasts.com/videos/67_restful_authentication.mov 
http://media.railscasts.com/videos/66_custom_rake_tasks.mov 
http://media.railscasts.com/videos/65_stopping_spam_with_akismet.mov 
http://media.railscasts.com/videos/64_custom_helper_modules.mov 
http://media.railscasts.com/videos/63_model_name_in_url.mov 
http://media.railscasts.com/videos/62_hacking_activerecord.mov 
http://media.railscasts.com/videos/61_sending_email.mov 
http://media.railscasts.com/videos/60_testing_without_fixtures.mov 
http://media.railscasts.com/videos/59_optimistic_locking.mov 
http://media.railscasts.com/videos/58_how_to_make_a_generator.mov 
http://media.railscasts.com/videos/57_create_model_through_text_field.mov 
http://media.railscasts.com/videos/56_the_logger.mov 
http://media.railscasts.com/videos/55_cleaning_up_the_view.mov 
http://media.railscasts.com/videos/54_debugging_with_ruby_debug.mov 
http://media.railscasts.com/videos/53_handling_exceptions.mov 
http://media.railscasts.com/videos/52_update_through_checkboxes.mov 
http://media.railscasts.com/videos/51_will_paginate.mov 
http://media.railscasts.com/videos/50_contributing_to_rails.mov 
http://media.railscasts.com/videos/49_reading_the_api.mov 
http://media.railscasts.com/videos/48_console_tricks.mov 
http://media.railscasts.com/videos/47_two_many_to_many.mov 
http://media.railscasts.com/videos/46_catch_all_route.mov 
http://media.railscasts.com/videos/45_rjs_tips.mov 
http://media.railscasts.com/videos/44_debugging_rjs.mov 
http://media.railscasts.com/videos/43_ajax_with_rjs.mov 
http://media.railscasts.com/videos/42_with_options.mov 
http://media.railscasts.com/videos/41_conditional_validations.mov 
http://media.railscasts.com/videos/40_blocks_in_view.mov 
http://media.railscasts.com/videos/39_customize_field_error.mov 
http://media.railscasts.com/videos/38_multibutton_form.mov 
http://media.railscasts.com/videos/37_simple_search_form.mov 
http://media.railscasts.com/videos/36_subversion_on_rails.mov 
http://media.railscasts.com/videos/35_custom_rest_actions.mov 
http://media.railscasts.com/videos/34_named_routes.mov 
http://media.railscasts.com/videos/33_making_a_plugin.mov 
http://media.railscasts.com/videos/32_time_in_text_field.mov 
http://media.railscasts.com/videos/31_formatting_time.mov 
http://media.railscasts.com/videos/30_pretty_page_title.mov 
http://media.railscasts.com/videos/29_group_by_month.mov 
http://media.railscasts.com/videos/28_in_groups_of.mov 
http://media.railscasts.com/videos/27_cross_site_scripting.mov 
http://media.railscasts.com/videos/26_hackers_love_mass_assignment.mov 
http://media.railscasts.com/videos/25_sql_injection.mov 
http://media.railscasts.com/videos/24_the_stack_trace.mov 
http://media.railscasts.com/videos/23_counter_cache_column.mov 
http://media.railscasts.com/videos/22_eager_loading.mov 
http://media.railscasts.com/videos/21_super_simple_authentication.mov 
http://media.railscasts.com/videos/20_restricting_access.mov 
http://media.railscasts.com/videos/19_where_administration_goes.mov 
http://media.railscasts.com/videos/18_looping_through_flash.mov 
http://media.railscasts.com/videos/17_habtm_checkboxes.mov 
http://media.railscasts.com/videos/16_virtual_attributes.mov 
http://media.railscasts.com/videos/15_fun_with_find_conditions.mov 
http://media.railscasts.com/videos/14_performing_calculations_on_models.mov 
http://media.railscasts.com/videos/13_dangers_of_model_in_session.mov 
http://media.railscasts.com/videos/12_refactoring_user_name_part_3.mov 
http://media.railscasts.com/videos/11_refactoring_user_name_part_2.mov 
http://media.railscasts.com/videos/10_refactoring_user_name_part_1.mov 
http://media.railscasts.com/videos/9_filtering_sensitive_logs.mov 
http://media.railscasts.com/videos/8_layouts_and_content_for.mov 
http://media.railscasts.com/videos/7_all_about_layouts.mov 
http://media.railscasts.com/videos/6_shortcut_blocks_with_symbol_to_proc.mov 
http://media.railscasts.com/videos/5_using_with_scope.mov 
http://media.railscasts.com/videos/4_move_find_into_model.mov 
http://media.railscasts.com/videos/3_find_through_association.mov 
http://media.railscasts.com/videos/2_dynamic_find_by_methods.mov 
http://media.railscasts.com/videos/1_caching_with_instance_variables.mov

希望对你有帮助!

呵呵,别把人家服务器下载爆了 :)

本文转自敏捷的水博客园博客,原文链接http://www.cnblogs.com/cnblogsfans/archive/2010/10/10/1847174.html如需转载请自行联系原作者


王德水

相关文章
|
算法 测试技术 API
如何用Ruby语言提高代码的可读性和可维护性
在软件开发过程中,代码的可读性和可维护性是非常重要的因素。一旦代码变得难以理解和修改,就会导致开发速度变慢、bug增多以及团队合作效率下降。在本篇博客中,我们将探讨一些使用Ruby编程语言的技巧和最佳实践,以提高代码的可读性和可维护性。
88 1
|
6月前
|
JSON 监控 数据可视化
局域网管理软件的Ruby代码实践
使用Ruby进行局域网管理的实践,包括安装`net-ping`库进行设备扫描、利用`packetgen`监控流量、执行文件备份自动化任务和数据可视化,以及通过HTTP提交数据。示例代码展示了Ruby在局域网管理中的灵活性和效率。
300 5
|
3月前
|
开发者 数据库 虚拟化
Xamarin 应用性能优化策略大揭秘,从代码到界面再到数据访问,全面提升应用性能,快来围观!
【8月更文挑战第31天】在 Xamarin 跨平台移动应用开发中,性能优化至关重要。代码优化是基础,应避免不必要的计算与内存分配,如减少循环中的对象创建及合理使用数据结构。界面设计上需注意简化布局、减少特效并启用虚拟化以提升响应速度。数据访问方面,优化数据库查询和网络请求可显著改善性能。Xamarin Profiler 等工具还可帮助开发者实时监控并优化应用表现,从而打造流畅高效的用户体验。
51 0
|
3月前
|
开发者 UED Ruby
Ruby中的异常处理之谜:如何用异常与rescue让你的代码坚不可摧?
【8月更文挑战第31天】在软件开发中,错误处理对应用稳定性至关重要。作为动态、面向对象的语言,Ruby提供了丰富的错误处理机制,如异常与rescue。本文通过示例代码介绍了Ruby中的异常类型、异常链及rescue与else的使用,展示了如何优雅地处理各种错误情况,增强了程序的健壮性和用户体验。使用这些机制,开发者能更精准地识别并解决运行时问题,提升应用质量。随着Ruby生态的发展,错误处理的重要性将愈发凸显。
40 0
|
3月前
|
开发者 Ruby
神秘编程魔法惊现!Ruby 元编程究竟隐藏着怎样的力量?竟能让代码自我进化!
【8月更文挑战第31天】《Ruby元编程:让代码自我进化》介绍了Ruby元编程的魅力,通过动态修改代码结构和行为,实现代码自我进化。文章通过实例展示了如何使用`class_eval`动态添加属性和方法,以及通过别名修改现有方法。此外,还介绍了利用模块实现代码复用和扩展。元编程为开发者提供了极大的灵活性和创造力,使代码更加动态高效。
26 0
|
3月前
|
Ruby
Ruby游戏开发揭秘:如何用简单的代码构建你的第一个猜数字游戏?
【8月更文挑战第31天】在编程学习之旅中,开发简易游戏是理解基础概念如控制流程、输入输出及数据结构的好方法。本指南将带你从零开始,用 Ruby 构建一个猜数字游戏。游戏设计为让玩家猜一个 1-100 间的随机数。文中详细介绍了所需环境的搭建过程、代码编写步骤,包括初始化游戏、处理猜测、读取输入和启动游戏循环的核心逻辑。完成这些后,你不仅能拥有一个功能完备的游戏,还将掌握 Ruby 的基本语法与特性,为进一步探索编程世界打下坚实的基础。
34 0
|
3月前
|
测试技术 开发者 Ruby
Ruby领域特定语言(DSL)的神秘力量:如何让你的代码飞起来?
【8月更文挑战第31天】在软件开发领域,Ruby以简洁的语法和强大的表达能力著称,但面对复杂业务逻辑时,代码可能变得冗长难维护。此时,领域特定语言(DSL)成为解决问题的有效途径。DSL专为特定领域设计,使代码更贴近业务逻辑,提高可读性和可维护性。本文通过示例展示了如何在Ruby中开发DSL,包括使用解析器和宏功能创建一个简单的Web应用结构描述语言,并提出了定义清晰语法、避免滥用DSL等最佳实践,强调了测试与文档的重要性。
61 0
|
6月前
|
存储 JavaScript 编译器
这款国产中文编程火了!通过文言文编译生成Python、JS、Ruby代码!
这款国产中文编程火了!通过文言文编译生成Python、JS、Ruby代码!
255 0
|
安全 JavaScript 程序员
Ruby 代码清洁之道 (翻译)
Ruby 代码清洁之道 (翻译)
|
Java Linux 应用服务中间件
在 Ruby on Rails 应用程序中重用 Java 代码
在 Ruby on Rails 应用程序中重用 Java 代码