Skip to content

Instantly share code, notes, and snippets.

@nortikin
Last active August 29, 2015 14:17
Show Gist options
  • Save nortikin/11a818cb891d43f50ebd to your computer and use it in GitHub Desktop.
Save nortikin/11a818cb891d43f50ebd to your computer and use it in GitHub Desktop.
УФМС Кирпичная, 32. Отслеживать списки.
# -*- coding: utf8 -*-
import urllib
import re
import sys
def wget(url):
ufile = urllib.urlopen(url)
if ufile.info().gettype() == 'text/html':
return ufile.read()
def main():
if len(sys.argv) != 2:
print '''использование: python kirp.py [Номер по списку]'''
sys.exit(1)
number = sys.argv[1]
try:
kirp32 = wget('http://vk.com/kirp32')
except:
print 'Не могу ничего скачать, проверьте наличие Сети.'
sys.exit(1)
match = re.search('(\d+)\s({0})'.format(number), kirp32)
if not match:
print('Номера {0} нет в списке, увы.'.format(number))
return
print('{1} в списке под номером {0}.').format(match.group(1),match.group(2))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment