meta tag parsing in Rails [closed]

2019-07-19 13:42发布

I was looking for something to help me parse general meta-tags from websites similar to this github project I found for open graph data. Here's a demo app.

Basically, I'd like to be able to have a user input a URL from a news site and have it retrieve from that the Title, Desc, etc., leaving as little work possible for the user. Before I go roll my own I was wondering if there was a current project / gem that exists similar to the project above? (as it only works with open graph and not general meta-tags)

I also noticed that facebook's linter does this as well even without open graph specific tags.

2条回答
来,给爷笑一个
2楼-- · 2019-07-19 14:10

I would recommend the Nokogiri gem. It is an HTML, XML, etc. parser so you can use it to parse pages on your own. The nice thing about this approach is that it affords you the most flexibility for your specific use case. You can use the gem to parse any meta and header tags as long as you can express them using XPath or CSS3 selectors.

查看更多
成全新的幸福
3楼-- · 2019-07-19 14:12

You can also try this free (for most) Open Graph API that I built: http://www.opengraph.io/

查看更多
登录 后发表回答