Python HTMLParser and Vkontakte randomizer

Finally I’ve finish my first “program” on Python. The task is to parse people’s id from web page where reposter’s id stores. Main problems were: web-page code is loading dynamically so there is no simple way to get ids from it, the best solution was – save section where id stores in .html file I wanted to catch id + nickname but list of pairs was not a good decision when random works I can’t create a list which stores all found ids, it wiped every iteration I have some unsupported chars in nicknames and they’d broke iteration I’ve get a lot of junk while scan .html so I used regex to avoid them I can’t add various ids in list withoutShort Read more…

Python HTMLParser

How to spent two days if you know nothing about Python: need parse HTML page code, where VK id and username of every person who shared post stores   with open(‘test.html’, ‘r’, encoding=’utf-8′) as content_file: read_data = content_file.read() from html.parser import HTMLParser import re class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): vk_id = str(attrs) for line in vk_id: vk = re.findall(‘/\S+$’, vk_id) vk_fnd = str(vk) if re.search(‘/\w+\’\)\]’, vk_fnd): global vk_read vk_read = vk_fnd for ch in [‘/’, ‘)’, ‘[‘, ‘]’, ‘”‘, “‘”]: if ch in vk_read: vk_read = vk_read.replace(ch, “”) def handle_data(self, data): global vk_name vk_name = str(data) assert isinstance(data, object) for line in vk_name: if re.match(‘\S+\s+\S+$’, vk_name): print(“@{0} – {1}”.format(vk_read, vk_name)) break parser = MyHTMLParser() parser.feed(read_data) Now I know more.Short Read more…

Заводим питончика дома или установка Python на Centos 6

Хороший гайд здесь: https://github.com/h2oai/h2o/wiki/Installing-python-2.7-on-centos-6.3.-Follow-this-sequence-exactly-for-centos-machine-only How to install Python 2.7.6 on CentOS 6.3 (6.2 and 6.4 okay too, probably others) stolen from Daniel Eriksson. Thanks Daniel! http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/ (modified a little) CentOS 6.2 ships with Python 2.6.6 and depends on that specific version. Be careful not to replace it or bad things will happen. If you need access to a newer version of Python you must compile it yourself and install it side-by-side with the system version. Here are the steps necessary to install Python 2.7.6. Execute all the commands below as root. Either log in as root temporarily or use sudo. Install development tools In order to compile Python you must first install the development tools: yum groupinstall “Development tools” You alsoShort Read more…

Perforce – Windows start investigation and install

Perforce is a commercial, proprietary revision control system developed by Perforce Software, Inc. by wiki Installation: Perforce requires at least two executables: the Perforce service (p4d), and at least one Perforce application (such as p4 on UNIX, orp4.exe on Windows). The Perforce service and applications are available from the Downloads page on the Perforce web site: http://www.perforce.com/downloads/complete_list Go to the web page, select the files for your platform, and save the files to disk. pics Windows installation is very easy. Config files and settings can be found and modified: This also can be used for Linux version of P4 Read more…

Perforce – Centos start investigation and install

The Perforce service and applications are available from the Downloads page on the Perforce web site: http://www.perforce.com/downloads/complete_list THIS is not a JOKE! Installation: Do not worked for me: Also do not work: Procedures above looks not complex, I cannot run P4 by them. Will try another: Another way don’t work: Doesn’t work: [root@testcentos perforce]# ./p4 info Perforce client error: Connect to server failed; check $P4PORT. TCP connect to perforce:1666 failed. Name or service not known [root@testcentos perforce]# ./p4d Perforce server error: Listen 1666 failed. TCP listen on 1666 failed. bind: 0.0.0.0:1666: Address already in use FINALLY It’s worked: Probably there is no output after ./p4d runs, but server is up and listen   Useful commands: p4 info   — This should show ifShort Read more…

All about Atlassian JIRA

Atlassian JIRA Пришло время взяться за исследование своего первого продукта на работке. На этот релиз мне выпала Atlassian JIRA вот она на фиц. сайте. В пользу продукта говорит то, что его очень просто установить, что он имеет бесплатную версию для некоммерческого использования и доступен как для Windows так и для Linux. По ходу работы мне предстоит выковырять из продукта всю необходимую информацию, после того как он будет установлен и настроен: install root – win+linux version: package active log or .reg license И пока все на этом, если дальше будут усложнять, то нужно будет, возможно проследить еще и каки-нибудь зависимости. Итак, установка: стоит сразу сказать, что установка до неприличного простая на обеих ОС, нужно просто скачать на указанном выше сайте самоустановщики-распаковщики требуемые дляShort Read more…

Python array

Начинаю учить Пайтон, буду набивать шпаргалки. lst = [‘spam’, ‘drums’, 100, 1234] print(lst[2]) 100 Это мой первый массив, детка. Спустя время, это может показаться для меня смешным, но сейчас я очень доволен собой. Read more…