diff --git a/test.php b/test.php deleted file mode 100755 index 2831960..0000000 --- a/test.php +++ /dev/null @@ -1,69 +0,0 @@ -([^<]*)<\/a><\/li>/', $response, $matches); - -// // Prepare the output for the readme file -// $output = ""; -// if (!empty($matches[1])) { -// foreach ($matches[1] as $href) { -// $output .= $href.PHP_EOL; -// } -// } else { -// $output = "No match found.\n"; -// } - -// // Write the results to readme.txt file -// file_put_contents("README.md", $output); - -// echo "Results saved to readme.txt"; -// } - -# 2 生成不同目录的文件夹 - -// Path to the README.md file -$readmePath = 'README.md'; - -// Read the file into an array of lines -$lines = file($readmePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - -$lines = [$lines[6]]; -foreach ($lines as $line) { - // Remove spaces from each line - $folderName = str_replace(' ', '', $line); - $folderName = "/Users/01397713/Documents/github/learn-tech".$folderName; - - $line = str_replace(' ', '%20', $line); - $curlUrl = $url. $line; - echo $curlUrl.PHP_EOL; - - $response = file_get_contents($curlUrl); - mkdir($folderName, 0777, true); - preg_match_all('/([^<]*)<\/a>/', $response, $matches); - - if (isset($matches[1])) { - $fileNameList = $matches[1]; - $urlList = $matches[2]; - - foreach($fileNameList as $key => $name) { - - $fileName = str_replace(' ', '', $name); - $fileName = $folderName . '/'. $fileName; - echo PHP_EOL; - - $uri = str_replace(' ', '%20', html_entity_decode($name)); - $fileUrl = $url . $line . '/' . $uri; - - echo $fileUrl; - echo PHP_EOL; - } - } - -} \ No newline at end of file