Get data from Yandex.XML service by XML
Yandex.XML service: https://xml.yandex.ru/settings/
Add this line to your application's Gemfile:
gem 'yandex_xml'
And then execute:
$ bundle
Or install it yourself as:
gem install yandex_xml
YandexXml has settings: user, key, region, keyword
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
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
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)
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/