RubyGems Navigation menu

mida 0.0.0

Mida

Description

A Microdata parser and extractor library for ruby. This is based on the latest Published version of the Microdata Specification dated 5th April 2011.

Installation

With Ruby and Rubygems:

gem install mida

Requirements:

  • Nokogiri

Usage

The following examples assume that you have required mida and open-uri.

Extracting Microdata from a page

All the Microdata is extracted from a page when a new Mida::Document instance is created.

To extract all the Microdata from a webpage:

url = 'http://example.com'
open(url) {|f| doc = Mida::Document.new(f, url)}

The top-level Items will be held in an array accessible via doc.items.

To simply list all the top-level Items that have been found: puts doc.items

Searching

If you want to search for an Item that has a specific itemtype/vocabulary this can be done with the search method.

To return all the Items that use one of Google’s Review vocabularies:

doc.search(%r{http://data-vocabulary\.org.*?review.*?}i)

Inspecting an Item

Each Item is a Mida::Item instance and has three main methods of interest, type, properties and id.

To find out the itemtype of the Item:

puts doc.items.first.type

To find out the itemid of the Item:

puts doc.items.first.id

Properties are returned as a hash containing name/values pairs. The values will be an array of either String or Mida::Item instances.

To see the properties of the Item:

puts doc.items.first.properties

Bugs/Feature Requests

If you find a bug or want to make a feature request, please report it at the Mida project’s issues tracker on github.

License

Copyright © 2011 Lawrence Woodman. This software is licensed under the MIT License. Please see the file, LICENSE.rdoc, for details.

Gemfile:
= 复制到剪贴板 已复制!

安装:
=

版本列表:

  1. 0.4.0 - August 08, 2016 (65.5 KB)
  2. 0.3.9 - January 13, 2016 (65.5 KB)
  3. 0.3.8 - June 03, 2014 (65.5 KB)
  4. 0.3.7 - June 03, 2014 (65.5 KB)
  5. 0.3.6 - September 22, 2013 (65.0 KB)
  6. 0.0.0 - April 12, 2011 (14.5 KB)
显示所有版本 (共 17 个)

Runtime 依赖 (1):

nokogiri >= 0

Development 依赖 (1):

rspec >= 0

业主:

作者:

  • Lawrence Woodman

SHA 256 校验和:

52073407f585d9f8ce9dcd27edbff4568f8b8c25f9689744bf5807e07d353a14

下载总量 204,629

这个版本 3,267

许可:

需要的 Ruby 版本: >= 1.9

链接: