-
Notifications
You must be signed in to change notification settings - Fork 29
/
update_list.py
33 lines (23 loc) · 1008 Bytes
/
update_list.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Update the search_engines.pickle list contained within the package.
Use this before deploying an update"""
from __future__ import absolute_import, division, print_function
import os
try:
import ujson as json
except ImportError:
import json
import ruamel.yaml as yaml
from six.moves.urllib.request import urlopen
_here = lambda *paths: os.path.join(os.path.dirname(os.path.abspath(__file__)),
*paths)
def main():
filename = _here('serpextract', 'search_engines.json')
print('Updating search engine parser definitions.')
url = urlopen('https://raw.githubusercontent.com/matomo-org/searchengine-and-social-list/master/SearchEngines.yml')
matomo_engines = yaml.safe_load(url)
with open(filename, 'w') as json_file:
json.dump(matomo_engines, json_file, indent=2, sort_keys=True)
print('Saved {} search engine parser definitions to {}.'
.format(len(matomo_engines), filename))
if __name__ == '__main__':
main()