Skip to content

Instantly share code, notes, and snippets.

@easychen
Created June 25, 2017 02:35
Show Gist options
  • Save easychen/6b2a60f0cee78e89859bfbd97ec6cc3c to your computer and use it in GitHub Desktop.
Save easychen/6b2a60f0cee78e89859bfbd97ec6cc3c to your computer and use it in GitHub Desktop.
微贝增强脚本:Json导出
<?php
foreach( glob( '*.html' ) as $k => $htmlfile )
{
echo "File $htmlfile ...";
$reg = '/this\.feeds\s+=\s+(.+?)\}\s+,\s+1000/is';
$content = file_get_contents( $htmlfile );
if( preg_match( $reg , $content , $out ) )
{
if($data = json_decode( trim($out[1]) , 1 ))
{
@mkdir( 'json/', 0777 , true );
$jsonfile = 'json/' . basename( $htmlfile ) . '.json';
file_put_contents( $jsonfile , trim($out[1]) );
echo "done.\r\n";
}
else
echo "error.\r\n";
}
}
echo "ALL Done.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment