×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    TclScripts/UrlGrab: Difference between revisions

    Content added Content deleted
    imported>mutante
    mNo edit summary
    imported>Kunda
    m (tweeked the page a bit, muta)
     
    (9 intermediate revisions by 4 users not shown)
    Line 1: Line 1:
    How to grab URLs from IRC channels ,save them to mysql, and display them on a webpage:
    === How to grab URLs from [[IRC]] channels, save them to [[mysql]], and display them on a webpage:===


    [http://rufus.o-town.de/eggdrop/pub/scripts1.x/urlgrab.tcl urlgrab.tcl v0.7] (by RufusDE <sup><Thomas.Koester</sup>AT<sup>rz.Uni-Osnabrueck.DE></sup>)<br>
    already handles all the [[Regular Expressions|regex]]'ing nicely, and because [[HackerAttitude|no problem should ever be solved twice]], we just take this one to start with.
    [http://rufus.o-town.de/eggdrop/pub/scripts1.x/urlgrab.tcl urlgrab.tcl v0.7] by RufusDE <Thomas.Koester@rz.Uni-Osnabrueck.DE>

    already handles all the [RegularExpressions regex]'ing nicely, and because [HackerAttitude no problem should ever be solved twice], we just take this one to start with.
    Note: It only logs to a text file though, but we have [http://rufus.o-town.de/(en)/eggdrop/pub/mysql/libmysqltcl.so-linux-glibc2-x86.tar.gz libmysqltcl] installed (on s23.org) so we can add MySql commands like this:


    It only logs to a text file though, but we have [http://rufus.o-town.de/(en)/eggdrop/pub/mysql/libmysqltcl.so-linux-glibc2-x86.tar.gz libmysqltcl] installed (on s23.org) so we can add MySql commands like this:
    <pre>
    <pre>
    # added sql insert by mutante
    # added sql insert by mutante
    Line 13: Line 13:
    mysqlclose $db
    mysqlclose $db
    </pre>
    </pre>
    <center>
    i inserted this between row 51 - 57 in the original script.
    I inserted this between row 51 - 57 in the original script.<br>
    replace <user> and <password> with your mysql user / pass.
    Replace '''<user>''' and '''<password>''' with your mysql user / pass.<br>

    You need to create a database "ircurls" with a table "urlgrab" or whatever you like,
    You need to create a database "ircurls" with a table "urlgrab" or whatever you like,<br>
    and the table structure is :
    and the table structure is:
    </center>

    <pre>
    <pre>
    Table structure for table `urlgrab`
    Table structure for table `urlgrab`
    Line 32: Line 32:
    ) TYPE=MyISAM;
    ) TYPE=MyISAM;
    </pre>
    </pre>
    <center>

    Now to the output part / webinterface:
    Now to the output part / webinterface:
    You can use f.e. php (or perl) to read from mysql:<br>

    You can use f.e. php (or perl) to read from mysql:

    Example:
    Example:
    </center>

    <pre>
    <pre>
    <?php
    <?php
    Line 49: Line 47:
    $urlnum=0;
    $urlnum=0;


    while ($myrow = mysql_fetch_row($result)) {
    echo "<html><head></head><body><table border="1"><tr><th colspan="5" >s23 - IRC URL log</th></tr>
    ";
    echo "<tr><th>id</th><th>URL</th><th>nick</th><th>chan</th><th>date</th></tr>
    ";

    while ($myrow = mysql_fetch_row($result)) {
    printf("<tr><td>%s</td><td><a target="new" href="%s">%s</a></td><td>%s</td><td>%s</td><td>%s</td></tr>
    printf("%s <a target="new" href="%s">%s</a> %s %s %s
    ",
    ",
    $myrow[0], $myrow[1], $myrow[1], $myrow[2], $myrow[3], $myrow[4],$myrow[5]);
    $myrow[0], $myrow[1], $myrow[1], $myrow[2], $myrow[3], $myrow[4],$myrow[5]);
    Line 62: Line 55:
    $urlnum++;
    $urlnum++;
    }
    }

    echo "<tr><td colspan="5">Total URLs found: $urlnum</td></tr>";
    echo "<tr><td colspan="5">Total URLs found: $urlnum</td></tr>";
    echo "</table></body></html>";
    echo "</table></body></html>";

    </pre>
    </pre>
    Which, if you play with it, looks something like:<br>
    http://mutante.s23.org/urllog.php , ('''Which is now a broken link''')<br>
    While creating all this i found out Rufus already offers [http://rufus.o-town.de/eggdrop/pub/mysql/ mysql_urlgrab.tcl], DOH!!!<br>
    So you could as well just use that, but i didnt check it out yet ;)<br>
    Rufus is also the maintainer of libmysqltcl himself it seems, so he should know pretty good.
    -[[User:mutante|mutante]]


    which looks something like:


    Related: [[Eggdrop]] | [[MySQL]]
    http://mutante.s23.org/urllog.php

    While creating all this i found out Rufus also offers [http://rufus.o-town.de/eggdrop/pub/mysql/ mysql_urlgrab.tcl] , DOH!

    So you could as well just use that ,but i didnt check it out yet ;)

    Rufus is also the maintainer of libmysqltcl himself it seems, so he should know pretty good.


    [[Category:Programming]]
    mutante
    [[Category:Scripts]]
    [[Category:IRC]]
    [[Category:TCL]]

    Latest revision as of 02:32, 25 October 2005

    How to grab URLs from IRC channels, save them to mysql, and display them on a webpage:[edit]

    urlgrab.tcl v0.7 (by RufusDE <Thomas.KoesterATrz.Uni-Osnabrueck.DE>)
    already handles all the regex'ing nicely, and because no problem should ever be solved twice, we just take this one to start with.

    Note: It only logs to a text file though, but we have libmysqltcl installed (on s23.org) so we can add MySql commands like this:

    # added sql insert by mutante 
    set db [mysqlconnect -host localhost -user <user> -password <password> -db ircurls]
    mysqlexec $db "INSERT INTO urlgrab SET url="$url",chan="$lchan",nick="$nick",date=now()"
    puthelp "privmsg mutante :Added to sql-db : url: $url chan: $lchan nick: $nick date: $ctime"
    mysqlclose $db  
    

    I inserted this between row 51 - 57 in the original script.
    Replace <user> and <password> with your mysql user / pass.
    You need to create a database "ircurls" with a table "urlgrab" or whatever you like,
    and the table structure is:

    Table structure for table `urlgrab`
    
    
    CREATE TABLE urlgrab (
      id int(5) unsigned NOT NULL auto_increment,
      url varchar(255) default NULL,
      nick varchar(32) default NULL,
      chan varchar(64) default NULL,
      date datetime NOT NULL default '0000-00-00 00:00:00',
      PRIMARY KEY  (id)
    ) TYPE=MyISAM;
    

    Now to the output part / webinterface: You can use f.e. php (or perl) to read from mysql:
    Example:

    <?php
    
     $db = mysql_connect("localhost", "<user>", "<pass>");
    
     mysql_select_db("ircurls",$db);
    
     $result = mysql_query("SELECT * FROM urlgrab",$db);
     $urlnum=0;
    
     while ($myrow = mysql_fetch_row($result)) {
      
      printf("%s <a target="new" href="%s">%s</a> %s %s %s 
    ", 
      $myrow[0], $myrow[1], $myrow[1], $myrow[2], $myrow[3], $myrow[4],$myrow[5]);
    
    $urlnum++;
    }
    
    echo "<tr><td colspan="5">Total URLs found: $urlnum</td></tr>";
    echo "</table></body></html>";
    

    Which, if you play with it, looks something like:
    http://mutante.s23.org/urllog.php , (Which is now a broken link)
    While creating all this i found out Rufus already offers mysql_urlgrab.tcl, DOH!!!
    So you could as well just use that, but i didnt check it out yet ;)
    Rufus is also the maintainer of libmysqltcl himself it seems, so he should know pretty good. -mutante


    Related: Eggdrop | MySQL

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.