Category ArchivejQuery
Category ArchivejQuery
jQuery & PHP & Programming Daantje on 10 Jun 2009
I’m now busy with writing a filter, to grep data out of an large based HTML website, build back in the old days. Luckily they’ve used class names to point out the right table cells. I thought it would be a great job for jquery… But server-side… Could it be possible?
After some googling I found this very interesting blog post: “Bringing the Browser to the Server“. A real great way to use a javascript lib like jquery or prototype server side!
I use PHP to grep the HTML and transfer it to valid XHTML so I can use it in rhino.
./html2xml.php [path/to/file.html]
#!/usr/bin/php -q
<?php
$doc = new DOMDocument();
$doc->loadHTMLFile($argv[1]);
$html = $doc->saveXML();
$html = str_replace('<script','<noscript',$html);
$html = str_replace('</script','</noscript',$html);
echo $html;
?>
Than I use jquery to grep all data and do an ajax request to a PHP file to insert the data into a database.
After some testing, my scripts only work wit an older version of jquery. I use 1.2.6, the later ones all give errors…
I’ll try to post more info and code later ;) Check my tweets for info too!