输出Div到文本文件

I know i asked a similar question, but this is way more general. Is there any way of saving a div (with a determinated class) content to a text file, in the current directory, on server side, and something that don't require the user to click, because i have 500+ pages to save the same div, every day. It can be in php (if used in a main page, to parse other html files), jquery, ajax, anything.

The pages looks like this

...
<div class="myClass">
*lots of stuff*
*lots of stuff*
*lots of stuff*
</div>
...

and every page have a different name, ex: 475.html, and it would output to 475.txt the .myclass div. Inside this div, i have some more divs, some, uls, lis, and etc.

I don't know ajax, i know a little bit of PHP, and some of jQuery. But i know, jscript alone won't let you access the filesystem by security reasons. So if possible, be very clear, and poit me the way.

Thank you :)

        $fileName = $_SERVER['REQUEST_URI']; // Gets the filename
        $fileName = str_replace('/',"",$fileName); //removes "/" string
        $fileName = str_replace('.html',"",$fileName); //removes ".html" string
        $myFile = "$fileName.txt";
        $fh = fopen($myFile, 'w') or die("can't open file");
        $stringData = '<div class="myClass">............';
        fwrite($fh, $stringData);
        fclose($fh);

is that what you want?