cmiN Posted May 11, 2011 Report Posted May 11, 2011 Pentru labatroni si cei care vor sa dea embed la p0rnache.[Python] rtc - Pastebin.com#! /usr/bin/env python3# redtube.com video link crawler# 11.05.2011import sys, urllib.request, threadingclass RTC(threading.Thread): def __init__(self, page): self.page = page threading.Thread.__init__(self) def run(self): word = b"stat['" with urllib.request.urlopen("http://www.redtube.com/?page=" + str(self.page)) as uin: source = uin.read() start = source.find(b"<!-- Preparation templates -->") end = source.find(b"<!-- Preparation templates end -->") start = source.find(word, start, end) while start != -1: start = start + len(word) string = "" while source[start] != ord("'"): string += chr(source[start]) start += 1 self.fobj.write("http://www.redtube.com/" + string + "\n") start = source.find(word, start, end)def main(argc, argv): if argc == 5: RTC.fobj = open(argv[1], "at") for page in range(int(argv[2]), int(argv[3]) + 1): while threading.active_count() > int(argv[4]): pass RTC(page).start() while threading.active_count() > 1: pass RTC.fobj.close() else: print("./rtc.py filename from to threads\n\filename: path to a text file for storing links\n\from: start page number\n\to: end page number\n\threads: how many pages to parse asinchronously\n")if __name__ == "__main__": main(len(sys.argv), sys.argv) Quote
cmiN Posted May 11, 2011 Author Report Posted May 11, 2011 A fost mai mult un challenge ... si m-am incadrat in 20 minute . Quote
Flubber Posted May 11, 2011 Report Posted May 11, 2011 De ce:[...]import sys, urllib.request, threading[...]Si nu:import sysimport urllib.requestimport threading?Din cate stiam, este recomandat "import" pe fiecare linie. Quote
cmiN Posted May 11, 2011 Author Report Posted May 11, 2011 Am mai auzit si eu de teoria asta, probabil adopta stilul de la C, acolo directivele nu le poti scrie pe aceeasi linie iar ca viteza mi se pare exact la fel chiar mai rapid (teoretic) de ce sa am N import cand pot avea unul singur la fel cum de ce sa am print("c") print("m")...etc cand pot avea print("c\nm\ni\nN") ? Quote