diff --git a/pyyaxml/example.py b/pyyaxml/example.py
index f99d92a..0087236 100644
--- a/pyyaxml/example.py
+++ b/pyyaxml/example.py
@@ -6,11 +6,14 @@
API_USER = ''
API_KEY = ''
-y = YaSearch(API_USER, API_KEY)
+# Put the desired region https://yandex.ru/dev/xml/doc/dg/reference/regions.html
+LR_S = '213'
+
+y = YaSearch(API_USER, API_KEY, LR_S)
results = y.search('питон', site='python.su', page=1)
if results.error is None:
for result in results.items:
print(result.url + ' ' + result.snippet)
else:
print(results.error.code + ' ' + results.error.description)
-
\ No newline at end of file
+
diff --git a/pyyaxml/search.py b/pyyaxml/search.py
index 9bec4a9..f79ab57 100644
--- a/pyyaxml/search.py
+++ b/pyyaxml/search.py
@@ -32,8 +32,8 @@ class YaSearch:
%s
0
-
-
+
+
"""
BASE_URL = u'https://yandex.{}/search/xml?'
@@ -48,9 +48,10 @@ def _xml_extract_helper(self, node):
result += self._xml_extract_helper(child)
return result.strip()
- def __init__(self, api_user, api_key, domain='ru'):
+ def __init__(self, api_user, api_key, lr=None, domain='ru'):
self._api_user = api_user
self._api_key = api_key
+ self._lr = lr
if domain not in self.VALID_DOMAINS:
raise ValueError('Invalid domain. Valid domains are {}'.format(', '.join(self.VALID_DOMAINS)))
self._url = self.BASE_URL.format(domain)
@@ -102,7 +103,7 @@ def search(self, query, page=1, site=None, max_page_num=100, sort_by='rlv', orde
request_suffix += (u' site:%s' % site)
page -= 1
- params = {'user': self._api_user, 'key': self._api_key}
+ params = {'user': self._api_user, 'key': self._api_key, 'lr': self._lr}
query = query + request_suffix
if PY2: