release
This commit is contained in:
commit
60b1523761
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.csv
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2017 Alexander Popov
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
36
cisoc.py
Normal file
36
cisoc.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import urllib.request
|
||||||
|
import lxml.html as html
|
||||||
|
import re
|
||||||
|
|
||||||
|
__author__ = 'Alexander Popov'
|
||||||
|
__version__ = '0.1.0'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
|
||||||
|
|
||||||
|
# get countryes list
|
||||||
|
def getList():
|
||||||
|
COUNTRY = list()
|
||||||
|
|
||||||
|
Html = html.parse(urllib.request.urlopen('https://countrycode.org/'))
|
||||||
|
table = Html.xpath('//div[@class="visible-sm visible-xs"]//table/tbody/tr')
|
||||||
|
for item in table:
|
||||||
|
result = re.findall(r'([A-Z].*)', item.text_content())
|
||||||
|
iso = result[1].split(' / ')
|
||||||
|
COUNTRY.append((result[0], iso[0], iso[1]))
|
||||||
|
|
||||||
|
return(COUNTRY)
|
||||||
|
|
||||||
|
|
||||||
|
# save countryes list in csv file
|
||||||
|
def CSV():
|
||||||
|
countryes = getList()
|
||||||
|
|
||||||
|
with open('./cisoc.csv', 'w+', encoding='utf-8') as f:
|
||||||
|
for country in countryes:
|
||||||
|
f.write('%s,%s,%s\n' % (country[0], country[1], country[2],))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
CSV()
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
lxml==3.7.2
|
Loading…
Reference in New Issue
Block a user