Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

website lookup scripts

Name: Anonymous 2007-07-30 1:11 ID:+r8Pf0iS

PASTE YOUR WEB SITE LOOKUP SCRIPTS

Here's mine for urban dictionary

(require (lib "url.ss" "net"))

(define (http-get url)
  (let loop ((data "") (port (get-pure-port (string->url url))))
    (let ((ln (read-line port)))
      (if (not (eof-object? ln))
          (loop (string-append data ln) port)
          (begin
            (close-input-port port)
            data)))))

(define (get-definition data)
  (regexp-match (regexp "<div class=\"def_p\">[ \\n]+<p>(.*?)</p>[ \\]+<p style=\"font-style: italic\">(.*?)</p>") data))

(define (strip-definition definition)
  (let* ((br-stripped (regexp-replace* (regexp "<br />\r") definition " "))
         (a-stripped (regexp-replace* (regexp "<a href=\".*?\">(.*?)</a>") br-stripped "\\1"))
         (quot-trans (regexp-replace* (regexp "&quot;") a-stripped "\"")))
    quot-trans))

(define (html-definition term)
  (let ((http-data (http-get (string-append "http://www.urbandictionary.com/define.php?term=";
                                            (regexp-replace* " " term "+")))))
    (get-definition http-data)))

(define (limit term definition)
  (define (lowest a b) (if (< a b) a b))
  (let ((limit 256))
    (string-append (substring definition 0 (lowest (string-length definition) limit))
                   (if (> (string-length definition) limit)
                       (string-append "... [snip] more: http://www.urbandictionary.com/define.php?term="; term)
                       ""))))
 
(define (udict term)
  (let ((definition (html-definition term)))
    (if (not (eq? definition #f))
        (limit term (strip-definition (string-append (cadr definition) " Example: " (caddr definition))))
        "")))


Examples:

> (display (udict "horrorshow"))
Part of the 'Nadsat' vocabulary used by Alex in Anothony Burgess' Novel 'A Clockwork Orange', Horrorshow was derived by Burgess from the russian word 'Khorosho' meaning well or good.  Example: real horrorshow (very good)

> (display (udict "in-out in-out"))
english slang term for sex, publicized in the movie clockwork orange Example: ...so me and the other droogs were gettin ready for some of the 'ol in-out, in-out

> (display (udict "4chan"))
you have just entered the very heart, soul, and life force of the internet. this is a place beyond sanity, wild and untamed. there is nothing new here. "new" content on 4chan is not found; it is created from old material. every interesting, offensive, shoc... [snip] more: http://www.urbandictionary.com/define.php?term=4chan

Etc.

Name: Anonymous 2007-07-31 1:58 ID:jzMghiv3

whoa, thats neat.

Name: Anonymous 2007-07-31 4:02 ID:SYpYZmzC

PHP Bash.org Quote Retrieval

function getBash() {
    $address = "http://www.bash.org/?random";;
    $txt = file_get_contents($address);
    if (strpos($txt, "does not exist")) {
        echo "Quote not found";
    }
    $start = '<p class="qt">';
    $end = '</p>';
    $quotes = $this->finds($start, $end, $txt);
    $start = 'title="Permanent link to this quote."><b>';
    $end = '</b>';
    $num = $this->finds($start, $end, $txt);
    $start = 'class="qa">+</a>(';
    $end = ')<a href';
    $score = $this->finds($start, $end, $txt);
    $quotes = $num.' - Score '.$score.'{{}}}{}}{}{{{}}}'.$quotes;
    $quotes = str_replace("<br />", "{{}}}{}}{}{{{}}}", $quotes);
    echo $quotes;
    $quotes = htmlspecialchars_decode($quotes);
    $quotes = explode("{{}}}{}}{}{{{}}}", $quotes);
    foreach ($quotes as $quote) {
    echo TTrim($quote);
}

function TTrim($text) {
    return str_replace("\n", "", str_replace("\r", "", trim($text)));
}

Name: Anonymous 2007-07-31 4:04 ID:SYpYZmzC

>>3
Forgot this function

    function finds($start, $end, $txt) {
        $spos = strpos($txt, $start);
        $epos = strpos($txt, $end, $spos);
        $sn = $spos + strlen($start);
        $en = $epos;
        $len = $en - $sn;
        $quote = substr($txt, $sn, $len);
        return $quote;
    }

Name: Anonymous 2007-07-31 4:17 ID:L+XtThDs

>>3,4
Oooo. Cool one. I think I'll try writing that in Scheme!

Name: Anonymous 2007-07-31 4:47 ID:9Ne51Nbf

>>3,4
Wow. That was crappy.

Name: Anonymous 2007-07-31 5:21 ID:L+XtThDs

Scheme bash.org quote retrieval

(load "http-get.ss")

(define (translate-tags source)
  (let* ((br-stripped (regexp-replace* (regexp "<br />\r") source " "))
         (quot-trans (regexp-replace* (regexp "&quot;") br-stripped "\""))
         (left (regexp-replace* (regexp "&lt;") quot-trans "<"))
         (right (regexp-replace* (regexp "&gt;") left ">")))
    right))

(define (bash-quote page-source)
  (let ((quote-source
         (regexp-match
          (regexp (string-append "<p class=\"quote\">.*?<b>#([0-9]+)</b>.*?</p>"
                                 ".*?"
                                 "<p class=\"qt\">(.+?)</p>")) page-source)))
    (if quote-source
        (cons (cadr quote-source) (translate-tags (caddr quote-source)))
        #f)))

(define (bash-random-with-id)
  (bash-quote (http-get "http://www.bash.org/?random";)))

(define (bash-random)
  (let ((quote (bash-random-with-id)))
    (if quote (cdr quote) #f)))

(define (bash id)
  (let ((quote (bash-quote (http-get (string-append "http://www.bash.org/?"; id)))))
    (if quote (cdr quote) #f)))


Example usage

> (display (bash-random))
<Eph> ahhhhhh tits , that`s thing I didn`t see for long now ...ahhhhhh <honx> eph: how can you be on the internet and not see tits for a long time?
> (display (bash-random-with-id))
(440 . <blazemore> we know your hand gets more action jax0ring than your feet do walking <scar`1> yeah well that's also caused by the fact that i hardly walk)
> (display (bash "440"))
<blazemore> we know your hand gets more action jax0ring than your feet do walking <scar`1> yeah well that's also caused by the fact that i hardly walk
> (display (bash-random))
(@Asimov) bah, i've got a life (@Asimov) i just dont let it interfere with my irc :)[/i]
> (display (bash-random))
<slutknght> has anyone registered microsoft.org or .net?[/i]
> (display (bash-random))
<FRoGGuM> So where the hell do u get this bot program?[/i]

Name: Anonymous 2007-07-31 5:23 ID:Heaven

I think there's a er function to translate HTML source to normal string (i.e. &lt; to <). I'll have to look it up.

Name: Anonymous 2007-07-31 5:28 ID:SYpYZmzC

>>6

Go fuck a rake

Name: Anonymous 2007-07-31 6:22 ID:xnCUbLRo

>>3

$quotes = str_replace("<br />", "{{}}}{}}{}{{{}}}", $quotes);
...
$quotes = explode("{{}}}{}}{}{{{}}}", $quotes);


lol web programmers

Name: Anonymous 2007-07-31 6:23 ID:L+XtThDs

>>10
WHAT THE FUCK
lol... web programmers

Name: Anonymous 2007-07-31 6:43 ID:SYpYZmzC

>>10
I think its a secret encoded message

Name: Anonymous 2007-07-31 6:56 ID:xnCUbLRo

>>12
I think you're trying to cover for your w3schools-taught incompetence.

Name: Anonymous 2007-07-31 7:03 ID:aJ0HJCCv

>>9
Which end?

Name: Anonymous 2007-07-31 9:45 ID:SYpYZmzC

>>13

How did you know?

Name: Anonymous 2007-07-31 9:50 ID:Heaven

>>15
EXPERT PROGRAMMERS always know.

Name: Anonymous 2007-07-31 10:01 ID:zdfqTyf4

>>15
OKAY YOU FUQIN ANGERED AN EXPERT PROGRAMMER
GODFUCKIGNDAMN
FIRST OF ALL, YOU DONT FUQIN KNOW WHAT A MAN PAGE IS
SECONDLY, THIS IS /prog/ DO NOT DEMAND USEFUL ANSWERS THE WAY YOU WANT THEM TO BE
THIRDLY PROGRAMMING IS ALL ABOUT PHILOSOPHY AND ``ABSTRACT BULLSHITE'' THAT YOU WILL NEVER COMPREHEND
AND FUQIN LASTLY, FUCK OFF WITH YOUR BULLSHYT
EVERYTHING HAS ALREADY BEEN ANSWERED IN
>>16

Name: Anonymous 2009-03-06 6:36


The shit outta you.

Name: Anonymous 2011-02-04 12:26


Don't change these.
Name: Email:
Entire Thread Thread List