-
Notifications
You must be signed in to change notification settings - Fork 107
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
How I can pass a HTML string to LinkThumbnailer #138
Comments
There is no public method available for this use case. However, you can try calling the following directly code directly: source = "<html>...</html>"
scraper = LinkThumbnailer::Scraper.new(source, "http://fake.come")
scraper.call Note that you will need to pass a URL anyway because LinkThumbnailer expects one, but it's only to prefill the URL attribute of the response object. |
@gottfrois Thanks, I'll try this. Would be nice to have public method for this, in my case I need to scrap html for other data also and currently I didn't find other option but to make two requests one from LinkThumbnailer another to get html content for my needs. |
@gottfrois I tried your suggestion but have an error: undefined method 'host' for #String:0x00007f9fcd043e80 on line |
Ah, the URL should be a |
@gottfrois Thanks, that worked. However I have another issue now, I moved the code into a service class, and it stopped working, I have following error |
Yeah this code is not the best... :( https://github.com/gottfrois/link_thumbnailer/blob/master/lib/link_thumbnailer/scraper.rb#L28 Don't remember why i proxied I don't see a quick fix for this other than monkey patching or changing the code of the gem and make it easier to scrap html directly. |
Are there plans for new release with direct html parsing support? I'd use that. |
No plans really but I'd gladly accept a PR |
How I can pass a HTML string to LinkThumbnailer to make it parse it instead of opening URL?
Couldn't find anything about it in the documentation or issues.
The text was updated successfully, but these errors were encountered: