Skip to content

Instantly share code, notes, and snippets.

@aceberg
Last active Aug 29, 2015
Embed
What would you like to do?
Search rutracker.org for films in 'mynamelist.txt'. If not found write film name in 'result_list'
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# created by x0x01 (aka.x0x01[AT]gmail[dot]com)
import urllib, urllib2, cookielib
import re
from string import strip
LOGIN = 'User'
PASS = 'password'
OUT_DIR = '/home/user/rutracker/'
# формирование кук
post_params = urllib.urlencode({
'login_username' : LOGIN,
'login_password' : PASS,
'login' : '%C2%F5%EE%E4'
})
# инит обработчика кук
cookie = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie))
urllib2.install_opener(opener)
# авторизация + сессия с куками
web_obj = opener.open('http://login.rutracker.org/forum/login.php', post_params)
data = web_obj.read()
file_film_list = open('mynamelist.txt', 'r')
film_list = file_film_list.readlines()
file_film_list.close()
r_list = open('result_list', 'w')
for film_name in film_list:
print 'Searching for: ', film_name
search_url = 'http://rutracker.org/forum/tracker.php?nm='+film_name
web_obj = opener.open(search_url, post_params)
data = web_obj.read()
if not re.search("leechmed", data):
r_list.write(film_name),
print 'Not found!'
r_list.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment