Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local file support #60

Open
neves opened this issue Oct 20, 2016 · 3 comments
Open

local file support #60

neves opened this issue Oct 20, 2016 · 3 comments

Comments

@neves
Copy link

neves commented Oct 20, 2016

Wombat can't parse local files:
/.gem/ruby/2.3.1/gems/wombat-2.5.1/lib/wombat/processing/parser.rb:33:in block (2 levels) in initialize': undefined method content_type' for #<Mechanize::FileResponse:0x007fe856a62d90> (NoMethodError)

@fwolfst
Copy link

fwolfst commented May 11, 2017

I have the same issue. In principle it should work using the "file://" protocol with mechanize or creating a Mechanize page or file by hand and setting it via page(https://github.com/felipecsl/wombat/wiki) . However in practise this did not work for me. I really would like to see that work.

http://stackoverflow.com/questions/7586627/read-a-local-html-file-with-mechanize lists a FakeWeb workaround (another could be a dead simple proxy server), but I'd really like to see this working in wombat directly.

@fwolfst
Copy link

fwolfst commented May 11, 2017

I would really prefer to use the page mechanism but have no time looking into why mechanize fails there.

For prototyping I now use webmock like this:

require 'webmock'
include WebMock::API

WebMock.enable!
stub_request(:get, "www.example.com").to_return(body: File.read("page.html"))

result = Wombat.crawl do
  base_url "http://www.example.com"
  path "/"
  # ...
end

@KrassCodes
Copy link

Thanks @fwolfst! Your approach with webmock worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants