huyha85 / opengraph_parser Goto Github PK
View Code? Open in Web Editor NEWSimple Ruby Parser library for parsing OpenGraph protocol (http://ogp.me)
License: MIT License
Simple Ruby Parser library for parsing OpenGraph protocol (http://ogp.me)
License: MIT License
Anchor tags are a valid part of an URI but shouldn't be included in the request.
url = "http://www.cnet.com/news/pi-top-the-3d-printable-raspberry-pi-laptop-anyone-can-build/#ftag=CAD590a51e"
require 'uri'
require 'open-uri'
require 'nokogiri'
p Nokogiri::HTML(open URI.parse(url), &:read).css('title').text #=> "Pi-Top: The 3D-printable Raspberry Pi laptop anyone can build - CNET"
require 'opengraph_parser'
p OpenGraph.new(url).title #=> "Page Not Found (404) - CNET"
Introduced in 2d828be, lib/redirect_follower.rb#28
Unfortunately, get_response doesn't work that way: ruby-doc.org. Passing a second argument (headers hash, empty or not) causes it to use the first one as hostname, which doesn't work.
Minimal example: try RedirectFollower.new('http://google.com').resolve
with and without https.
Hi there!
I have a question to @huyha85. Do you continue to maintain this gem? I want to push some changes to this repository. Will you accept PR and push the new version to Rubygems?
Pointing opengraph_parser to a big file or stream will make it read that until terminates, causing high memory usage and eventually a DoS if user input is passed to it.
Obvious solution would adding a Timeout.timeout, but since that's inherently thread unsafe, please don't do it.
A viable solution I see would be making a head request and looking at the Content-Type header. If it's not text/html don't continue. Other heuristics could be applied there, for example checking Content-Length.
Currently it does nothing.
Could also respond to body?
.
most gems include the tests. It would help us package the gem directly in debian. Now we take the github snapshots from tags. Can you please include the spec directory in the gem itself?
Hi, not an issue, just a question :)
require 'opengraph_parser'
fb = OpenGraph.new 'https://www.facebook.com/smashmag/')
puts fb.metadata[property="al:ios:url"]# => nothing
require 'opengraph_parser'
fb = OpenGraph.new('https://www.facebook.com/smashmag/')
puts fb.metadata# => {:title=>[{:_value=>"Smashing Magazine"}], :description=>[{:_value=>"Smashing Magazine. 291 378 Me gusta. Smashing Magazine delivers useful and innovative information to Web designers and developers."}], :image=>[{:_value=>"https://scontent-mad1-1.xx.fbcdn.net/v/t1.0-1/p200x200/17352146_10155179903597490_6515514170610847005_n.png?oh=a76c1ec8e8c526aa557545968c5a03ea&oe=598C27D2"}], :url=>[{:_value=>"https://www.facebook.com/smashmag/"}]}
The info I am trying to get is <meta property="al:ios:url" content="fb://page/?id=45576747489" />
Is that possible?
I tried your gem and it workes quite well. But it would be nice if you could also support ssl encrypted urls, because they are wide spreaded.
I would suggest the following change in line 15:
require 'net/https'
uri = URI.parse(URI.escape(url))
if uri.scheme == 'https'
https = Net::HTTP.new(uri.host, 443)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
self.response = https.request_get(uri.request_uri)
else
self.response = Net::HTTP.get_response(uri)
end
Would be great seeing this integrated, currently can't find time to build a pull request.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.