<?php/*
To use this script, execute the following commands in bash:
wget -k -E -l inf -r http://wokcanocafe.com/delivery.php
cd wokcanocafe.com
for foo in `egrep -o 'prod_show.php\?code_no=[0-9]+' *`; \
    do wget -E http://wokcanocafe.com/$foo; done

#and maybe 

for foo in  `ls prod* | egrep -o [0-9][0-9]+`; do mv \
    prod_show.php\?code_no=$foo.1.html prod_show.php\?code_no=$foo.html; done

# then
php scrape.php > output.html

*/
?>
<html><head><title>Wokcano Menu</title>

<style type="text/css">
<!--
.h{
    font-size: 200%;
    font-weight: bold;
}

.t{
    font-size: 130%;
    font-weight: bold;
}

.p{
    font-weight: bold;
}

.d{
    border-bottom: 2px solid #c0c0c0;
}

body, td{
    font-family: sans-serif;
}
-->
</style>

</head>

<body>

<p>This menu was generated by a PHP script from <a
href="http://www.wokcanocafe.com/">http://www.wokcanocafe.com/</a> on December
31, 2005. It exists because the online Wokcano menu is not accessible after
delivery hours "end" at 10 PM. In reality, you can probably get Wokcano to deliver until
at least 3 AM on weekends.
</p>
<p>I have corrected a few typos. There may be other inaccuracies or omissions.
This should not be considered authoritative.</p>

<p>Wokcano's phone number is 1-866-WOKCANO. The Pasadena Wokcano is (626)
578-1818, and you may have better luck with this number if you want to order
after 10 PM. (I've never used the toll-free number, so I don't know.) They're at
33 S. Fair Oaks Ave. (Go to Colorado, turn left [west], and then turn left on
Fair Oaks.) </p>
<ul>
<?php

function fixup($str){
    return 
str_replace(' n '' &amp; '$str);
}

$j 0;
foreach(
glob('delivery.php\?*secondgroup*') as $filename){
    
$j++;
    
preg_match('/maingroup=([^&]*)&secondgroup=(.*?).html/'$filename$matches);
    
$matches[1] = urldecode($matches[1]);
    
$matches[2] = fixup(urldecode($matches[2]));
    
$out .= "<tr><td colspan='2' class='h'>";
    
$out .= "<a id='a$j'></a>$matches[1] &gt; $matches[2]</td></tr>\n";
    echo 
"<li><a href='#a$j'>$matches[1] &gt; $matches[2]<a></li>\n";
    
$fc file_get_contents($filename);
    
preg_match_all('/href="[^"]*"  onclick= "window.open\(\'(prod_show.php\?code_no=\d+)[^"]*">([^<]*)(<img.*?>)?<\/FONT>[^$]*\$(\d+.\d+)/i',
        
$fc$matches); 
    for(
$i 0$i count($matches[0]); $i++){
        
$out .= '<tr><td class="t">' fixup($matches[2][$i]);
        if (
$matches[3][$i] != ''$out .= ' [spicy]';
        
$out .= '</td>';
        
$out .= '<td class="p">' $matches[4][$i] . '</td></tr>';
        
$out .= '<tr><td class="d" colspan="2">';
        
$dfile $matches[1][$i] . ".html";
        
$dfc file_get_contents($dfile);
        
preg_match('/^([^<>]+?)(<img.*?>)?<P>/mi'$dfc$m2);
        
$out .= fixup($m2[1]);
        
$out .= "</td></tr>\n";
    }
}
echo 
"</ul><table>$out</table>";
?>
</body></html>