← All posts tagged code

hot-gay

Если кому-то интересно, то вот моя грепалка арабов. Из депенденсов только lxml, в качестве аргумента указывается число страниц на которых производится поиск.

#!/usr/bin/python
import sys
import lxml.html

def getMessages(page):
    juick = lxml.html.parse("http://juick.com/?page=%d" % page).getroot()
    messages = juick.xpath("//div[@class='msg']")
    for message in messages:
        nick = "".join(message.xpath(".//big//a[1]/text()"))
        text = " ".join(message.xpath(".//div[@class='msgtxt']//text()"))
        n = "".join(message.xpath(".//div[@class='msgnum']//text()"))
        yield (nick, text, n)

def check(message):
    return (set(message) & set(map(unichr, xrange(0x600, 0x6ff + 1))))

def findPigs(pages):
    pigs = []
    for page in xrange(1, pages + 1):
        for message in getMessages(page):
            if check(message[1]):
                if pigs.count(message[0]) == 0:
                    pigs.append(message[0])
                    print message[0]

if __name__ == "__main__":
	findPigs(int(sys.argv[1]))

hot-gay

Зацените, пацаны, я запилил автообновляку тредов в веб-интерфейсе.
// ==UserScript==
// @name        juick thread update
// @namespace   juick
// @include     /^http://juick.com/.*/[0-9]+$/
// @version     1
// ==/UserScript==

function update_thread() {
	request = new XMLHttpRequest();
	request.open("GET", document.URL, false);
	request.send();
	parser = new DOMParser();
	thread = parser.parseFromString(request.responseText, "text/html");
	replies = document.getElementById("replies");
	replies.parentNode.replaceChild(thread.getElementById("replies"), replies);
}

intervalID = setInterval(update_thread, 1000);

hot-gay

Хоть я и не силён в JS, но раз уж такое дело, то вот скриптик.
// ==UserScript==
// @name        juick
// @namespace   juick
// @description juick
// @include     http://juick.com/*
// @version     1
// ==/UserScript==

var pigs = ["@cool", "@2nya", "@bia2admin", "@pesarak-2010", "@khalkhali", "@arbon", "@markazi2", "@persia", "@Mostafa0111", "@bandariha", "@day2day", "@angle", "@sense1star@jabber.org", "@mile", "@iranians", "@Parsi", "@roya4197", "@fench", "@persian-juick", "@Persian-Gulf", "@HOBAB", "@javane", "@Faz-", "@hamoon@talkonaut.com", "@hamoon@talkonaut.com", "@azade", "@ma", "@tak", "@kamyab", "@datis", "@FIGHTER", "@zahedanian", "@tamana", "@hAji", "@zoom1", "@mahdisjon", "@tannaz", "@paryaa", "@azra", "@botic0111", "@hami", "@azadi", "@chete...@xmpp.ru", "@sarab", "@hormoz", "@.shiva.@xmpp.ru", "@sami", "@parand", "@safacity", "@irc", "@ahora", "@paria", "@kaveh", "@Asia", "@nazi", "@love2love", "@Taha", "@whisky", "@nymoniouzz", "@AKARII", "@feri", "@APPLE"];

var sheet = document.createElement("style");
sheet.innerHTML = ".pig{opacity: 0.2;}";
document.body.appendChild(sheet);

var messages = document.getElementsByClassName("msg");
for (var message in messages) {
	var name = messages[message].firstChild.firstChild.firstChild.nodeValue;
	if (pigs.indexOf(name) != -1) {
		messages[message].setAttribute("class", "msg pig");
	}		
}