Mercredi 14 novembre 2007
Cette source est écrite en PL/SQL
Tourne sous Oracle 10g + (xe) [les autres j'ai pas testé]
Utilité : faire une sauvegarde de tout les liens présents sur les 100 pages des liens récents sur le site thepiratebay.org
Cette sopurce peut être reprise /distribuée/ etc etc etc ... :)
DECLARE
v_stream CLOB;
currentPosx NUMBER := 0 ;
posy NUMBER := 0 ;
seqstring VARCHAR2(400);
amt INTEGER := 1;
i NUMBER := 0;
iRecord NUMBER := 0;
iPage NUMBER := 0;
countData NUMBER := 0;
rawPerPage NUMBER := 30;
maxPages NUMBER := 100;
indexofRow NUMBER := 0;
TYPE Trecord IS TABLE OF VARCHAR2(200) ;
TYPE v_arr IS TABLE OF VARCHAR2(200) INDEX BY
BINARY_INTEGER;
Tvalues v_arr ;
Tbegin Trecord := Trecord('browse/',
'" title="',
'<a href="',
'title="',
'<td><b>',
'<a href="',
'right">',
'right">',
'right">' );
Tend Trecord := Trecord ('"',
'"',
'"',
'"',
'&',
'"',
'&',
'<',
'<');
BEGIN
-- up buffer size for output verification
DBMS_OUTPUT.ENABLE(500000);
DBMS_OUTPUT.PUT_LINE(' -- Start analyse script --');
-- get the html stream source code
FOR iPage IN 0..maxPages LOOP
v_stream := HTTPURITYPE.GETCLOB(HTTPURITYPE.CREATEURI(
'http://thepiratebay.org/recent/'||iPage ));
-- chck position of the '</thead>' ------------------------------HEADER --
currentPosx := DBMS_LOB.INSTR(v_stream, '</thead>', 1, 1);
v_stream :=REGEXP_REPLACE(DBMS_LOB.SUBSTR(v_stream,length(v_stream),currentposx), '[[:cntrl:]]', '');
FOR i IN 1..rawPerPage LOOP
FOR iRecord IN 1..Tbegin.COUNT LOOP
currentPosx := DBMS_LOB.INSTR(v_stream, Tbegin(iRecord), 1, 1);
v_stream := REGEXP_REPLACE(DBMS_LOB.SUBSTR(v_stream,length(v_stream), currentposx+length(Tbegin(iRecord)) ), '[[:cntrl:]]', '');
currentPosx := DBMS_LOB.INSTR(v_stream, Tend(iRecord), 1, 1);
seqstring := DBMS_LOB.SUBSTR(v_stream, currentPosx-length(Tend(iRecord)), 1) ;
Tvalues(iRecord) := seqstring ;
-- delete the record
v_stream := REGEXP_REPLACE(DBMS_LOB.SUBSTR(v_stream,length(v_stream),currentposx ), '[[:cntrl:]]', '');
END LOOP ; -- end iRecord
countData := countData +1;
INSERT INTO torrent (id,
category_number ,
title_link ,
loc_link ,
detail_link ,
time_link ,
url_link ,
size_link ,
seed ,
leech )
VALUES ( ((iPage*100)+i),Tvalues(1),Tvalues(2),Tvalues(3),Tvalues(4),Tvalues(5)
,Tvalues(6),Tvalues(7),Tvalues(8),Tvalues(9) );
END LOOP; -- end i
END LOOP; -- end iPage
DBMS_OUTPUT.PUT_LINE('Receved Data = '||countData);
-- DBMS_OUTPUT.PUT_LINE(v_stream);
END;
/
Enjoy !
par Dax
publié dans :
Peer-to-Peer
1
recommander
Retour à la page d'accueil