Skip to content
Gem yandex_xml. Get data from Yandex.XML service by XML
Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.yardoc
doc
lib
LICENSE
README.md
yandex_xml.gemspec

README.md

gem 'yandex_xml'

Get data from Yandex.XML service by XML

Yandex.XML service: https://xml.yandex.ru/settings/

Installation

Add this line to your application's Gemfile:

gem 'yandex_xml'

And then execute:

$ bundle

Or install it yourself as:

gem install yandex_xml

Usage

YandexXml has settings: user, key, region, keyword

Usage 1: Get data from Yandex.XML and create Hash with result

Method: get(keyword)

require 'yandex_xml'

parser = YandexXml.new(user: 'your_yandex_login',
  key: 'your_yandex_xml_key',
  region: 'your_yandex_region')

p parser.get('ruby on rails')
# => Hash with data

Results has data:

  • position,
  • url,
  • domain:,
  • title,
  • modtime,
  • size,
  • charset,
  • passage, # TODO: not work
  • passages_type,
  • mime_type,
  • saved_copy_url,
  • headline,
  • turbo_cgi_url,
  • turbo_fallback,
  • turbo_link

Usage 2: Get 100 urls (Yandex Top-100) from result

Method: get_top100_urls(keyword)

require 'yandex_xml'

parser = YandexXml.new(user: 'your_yandex_login',
  key: 'your_yandex_xml_key',
  region: 'your_yandex_region')

p parser.get_top100_urls('ruby')
# => Array with urls

Results has data: Array with URLs

Usage 3: Get position in Yandex Top-100 for site by keyword

Method: get_position(keyword, my_domain)

require 'yandex_xml'

parser = YandexXml.new(user: 'your_yandex_login',
  key: 'your_yandex_xml_key',
  region: 'your_yandex_region')

p parser.get_position('ruby on rails', 'rusrails.ru')
# => Position number or 0 if site not found in TOP-100 (Integer)

Results has data: Position number or 0 if site not found in TOP-100 (Integer)

Links and how get real data

Real data for your_yandex_login and your_yandex_xml_key remove and add from page https://xml.yandex.ru/settings/

Yandex regions: https://tech.yandex.ru/xml/doc/dg/reference/regions-docpage/

You can’t perform that action at this time.