extractdata.py
1 | from lxml import html |
2 | import requests |
3 | import json |
4 | |
5 | data = [] |
6 | |
7 | tplist = requests.get("https://translationproject.org/domain/index.html") |
8 | if(tplist.status_code == 200): |
9 | tree = html.fromstring(tplist.content) |
10 | domains = tree.xpath('//table/tr/td[1]/a/text()') |
11 | for d in domains: |
12 | data.append({"name": d, "system": 0}) |
13 | |
14 | with open('offlate/data.json', 'w') as f: |
15 | f.write(json.dumps(data)) |
16 |