yandex_xml 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/yandex_xml.rb +33 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 748231943ffb461959ebb4e682283c749a6c8b335b19f9931918a16b69b9b390
|
4
|
+
data.tar.gz: 34ef480451509f9c03ed3d7fb8dcf24ee6475d0cc8a741cf7eb2fdc605846698
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 36973c51c195acb148341427845c5e67cf2ae5911ea7a7affbafdf995839bd03bffc353e4ee6f105a7c583d805ff7918574ebc6a693ade0788ea925e420e23eb
|
7
|
+
data.tar.gz: 540f102c72d968a60e8bef98855d2417e05adebc9a422f2e5bf82dc343a29fe439d7b1e1f0c92ff090ea6ed09e76bee8e58b2ce66d8447ba6792bac2a0018fac
|
data/lib/yandex_xml.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Yandex.XML parser
|
2
|
+
# Author: https://github.com/krdprog/ - Alexey Tsaplin-Kupaysinov
|
3
|
+
# License: MIT
|
4
|
+
require 'net/http'
|
5
|
+
|
6
|
+
# Get data from Yandex.XML service by XML - https://xml.yandex.ru/settings/
|
7
|
+
class YandexXml
|
8
|
+
attr_accessor :keyword, :region
|
9
|
+
|
10
|
+
def initialize(attributes = {})
|
11
|
+
@user = attributes[:user]
|
12
|
+
@key = attributes[:key]
|
13
|
+
@region = attributes[:region]
|
14
|
+
end
|
15
|
+
|
16
|
+
# Get data from Yandex.XML service to XML format
|
17
|
+
def to_xml
|
18
|
+
create_xml_url
|
19
|
+
|
20
|
+
@yandex_xml_to_xml = Net::HTTP.get_response(URI.parse(@xml_url)).body
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# Create URL for query from Yandex.XML by XML
|
26
|
+
def create_xml_url
|
27
|
+
base_url = 'https://yandex.ru/search/xml?'
|
28
|
+
tail_url = '&groupby=attr%3Dd.mode%3Ddeep.groups-on-page%3D100.docs-in-group%3D1'
|
29
|
+
query_url = URI.encode_www_form([['user', @user], ['key', @key], ['query', @keyword], ['lr', @region]])
|
30
|
+
|
31
|
+
@xml_url = base_url + query_url + tail_url
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yandex_xml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexey Tsaplin-Kupaysinov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Get data from Yandex.XML service by XML
|
14
|
+
email: info@krdprog.ru
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/yandex_xml.rb
|
20
|
+
homepage: https://github.com/krdprog/yandex_xml
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.7.8
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Ruby application for Yandex.XML service
|
44
|
+
test_files: []
|