Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $cur_file_path = realpath(dirname(__FILE__));
- // Set File Names
- // Just place the input file in the same directory as this script
- $input_file = $cur_file_path . "/list_of_input_urls.txt";
- $output_file = $cur_file_path . "/list_of_output_urls.txt";
- /**
- Unless you know what you're doing I wouldn't change anything below
- **/
- $aBigAssArray = array();
- $pattern = "/\/product\/([aA-zZ 0-9]*)\//";
- // Check if input file exists
- if ( file_exists($input_file) ) {
- $input_handle = fopen($input_file, "r");
- $output_handle = fopen($output_file, "w");
- if ($input_handle) {
- while (($line = fgets($input_handle)) !== false) {
- preg_match($pattern, $line, $aResults);
- if ($aResults) {
- $asin = $aResults[1];
- if ( $asin ) {
- /** Uncomment if you wanted to store all values in an array. */
- // array_push($aBigAssArray, $asin);
- fwrite($output_handle, $asin . "\n");
- /** Uncomment to view lines as they're being processed */
- // echo $asin . "</br>";
- }
- }
- }
- fclose($input_handle);
- } else {
- // Error - Could not open file
- }
- /** Uncomment if you wanted to view each line stored in the array. */
- // foreach ($aBigAssArray as $asin_line):
- // echo $asin_line . "</br>";
- // endforeach;
- die('<hr>End Of Script');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement