构建将返回当前的rails web scraper应用程序 基于英国邮政编码的供水商(例如:EC2A 4BX)。创建了一个初始化文件,它可以在本地主机上运行,但在Heroku上我收到错误。 NameError:未初始化的常量网
Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: NameError: uninitialized constant Net
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/config/initializers/thameswater.rb:10:in `<top (required)>'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/railties-4.1.7/lib/rails/engine.rb:648:in `block in load_config_initializer'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.7/lib/active_support/notifications.rb:161:in `instrument'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/railties-4.1.7/lib/rails/engine.rb:647:in `load_config_initializer'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/railties-4.1.7/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/railties-4.1.7/lib/rails/engine.rb:611:in `each'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/railties-4.1.7/lib/rails/engine.rb:611:in `block in <class:Engine>'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/railties-4.1.7/lib/rails/initializable.rb:30:in `instance_exec'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/railties-4.1.7/lib/rails/initializable.rb:30:in `run'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/railties-4.1.7/lib/rails/initializable.rb:55:in `block in run_initializers'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/railties-4.1.7/lib/rails/initializable.rb:44:in `each'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/railties-4.1.7/lib/rails/initializable.rb:44:in `tsort_each_child'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/railties-4.1.7/lib/rails/initializable.rb:54:in `run_initializers'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/railties-4.1.7/lib/rails/application.rb:300:in `initialize!'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/config/environment.rb:5:in `<top (required)>'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/railties-4.1.7/lib/rails/application.rb:276:in `require_environment!'
remote: /tmp/build_b54ea2f35a53dd4aa97f18e85d315c40/vendor/bundle/ruby/2.0.0/gems/railties-4.1.7/lib/rails/application.rb:389:in `block in run_tasks_blocks'
require 'open-uri'
require 'nokogiri'
#Store URL to be scraped
uri = URI.parse('https://secure.thameswater.co.uk/dynamic/cps/rde/xchg/corp/hs.xsl/Thames_Water_Supply.xml')
https = Net::HTTP.new(uri.host,uri.port) **<---Error**
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
https.use_ssl = true
# we need to define a Post object and send the postcode to search
req = Net::HTTP::Post.new(uri.path)
req.set_form_data('postcode1' => 'RG1 8DB')
# do the post
result = https.request(req)
supplied = 'http://www.thameswater.co.uk/your-account/605_5460.htm'
not_supplied = 'http://www.thameswater.co.uk/your-account/605_5459.htm'
# evaluates the post result
if result.header['Location'] == supplied
puts 'Your property is in our supply area'
elsif result.header['Location'] == not_supplied
puts 'Sorry, we cant find your postcode'
end
答案 0 :(得分:3)
添加到您的dojo/parser::parse() error
Error: SyntaxError: syntax error in data-dojo-props='plugins:{indirectSelection: true,nestedSorting: true, filter: { closeFilterbarButton: true, ruleCount: 5, itemsName:
:
config/initializers/thameswater.rb