meta tag parsing in Rails [closed]

自作多情 提交于 2020-01-15 05:47:33

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/4916686/meta-tag-parsing-in-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!