Esempio n. 1
0
                    // Check if Sister URL is available
                    $SisterUrl = $SisterUrl_Ancher->getAttribute("href");
                }
                // if
                echo "{$i} - {$Bk_ISBN} - {$BookTitle} - {$Author} - {$Edition} - {$BK_UsedPrice} - {$BK_NewPrice} - {$BK_DigitalPrice} - {$ImageUrl} <br /> {$SisterUrl} <br /><br />";
                // Clearing Space
                unset($BookTitle);
                unset($SisterUrl);
                unset($Author);
                unset($Edition);
                unset($ImageUrl);
                unset($BK_UsedPrice);
                unset($BK_NewPrice);
                unset($BK_DigitalPrice);
                unset($Bk_ISBN);
            }
            // for
        }
    }
    // if
}
// Url Long books
$url = "http://www.bkstr.com/webapp/wcs/stores/servlet/CourseMaterialsResultsView?catalogId=10001&categoryId=9604&storeId=10161&langId=-1&programId=562&termId=100014525&divisionDisplayName=Graduate%20School%20of%20Business&departmentDisplayName=BUS&courseDisplayName=GSB%20101&sectionDisplayName=01&demoKey=null&purpose=browse";
// URL short Books
$url = "http://www.bkstr.com/webapp/wcs/stores/servlet/CourseMaterialsResultsView?catalogId=10001&categoryId=9604&storeId=10161&langId=-1&programId=562&termId=100014525&divisionDisplayName=Stanford&departmentDisplayName=CHEM&courseDisplayName=130&sectionDisplayName=01&demoKey=d&purpose=browse";
//$url = "http://www.bkstr.com/webapp/wcs/stores/servlet/CourseMaterialsResultsView?catalogId=10001&categoryId=9604&storeId=10161&langId=-1&programId=562&termId=100014525&divisionDisplayName=Graduate%20School%20of%20Business&departmentDisplayName=BUS&courseDisplayName=GSB%20101&sectionDisplayName=01&demoKey=d&purpose=browse";
MainBookData($url);
?>


Esempio n. 2
0
function ProcessDataDigging($file_name = "c:\\scrap\\book_data.csv")
{
    //xdebug_start_trace();
    $ProgramID = "647";
    $TermID = "100013708";
    $StoreId = "10742";
    $output = fopen($file_name, 'w');
    $row_data = "Program,Term,Department,Course,Section,Course URL,Book Title,BK Author,BK Edition,BK Image URL,BK Used Price,BK New Price,BK Digital Price,BK ISBN,Amazon List Price,Amazon Discount Price,Non Amazon New Price,Non Amazon Used Price,Amazon Detail Page URL,Detailed Link,Author(s),Edition,Publisher,ISBN (10),ISBN (13),ISBN (10) - Digi,ISBN (13) - Digi,List Price,You Pay Price\n";
    fwrite($output, $row_data);
    $Division_Name = " ";
    $Division_Name_url = str_replace(" ", "%20", $Division_Name);
    // Corrects The URL Data, removes spaces
    $Department_arr = file_get_contents("http://www.bkstr.com/webapp/wcs/stores/servlet/LocateCourseMaterialsServlet?requestType=DEPARTMENTS&storeId={$StoreId}&programId={$ProgramID}&termId={$TermID}&divisionName={$Division_Name_url}&_=");
    $Department_arr = str_replace("<script>parent.doneLoaded('", "", $Department_arr);
    $Department_arr = str_replace("')</script>", "", $Department_arr);
    $Department_arr = json_decode($Department_arr, true);
    $Department_arr = $Department_arr['data'][0];
    foreach ($Department_arr as $Department_Name => $Department_Value) {
        $Department_Name_url = str_replace(" ", "%20", $Department_Name);
        // Corrects The URL Data, removes spaces
        $Course_arr = file_get_contents("http://www.bkstr.com/webapp/wcs/stores/servlet/LocateCourseMaterialsServlet?requestType=COURSES&storeId={$StoreId}&programId={$ProgramID}&termId={$TermID}&divisionName={$Division_Name_url}&departmentName={$Department_Name_url}&_=");
        $Course_arr = str_replace("<script>parent.doneLoaded('", "", $Course_arr);
        $Course_arr = str_replace("')</script>", "", $Course_arr);
        $Course_arr = json_decode($Course_arr, true);
        $Course_arr = $Course_arr['data'][0];
        foreach ($Course_arr as $Course_Name => $Course_Value) {
            $Course_Name_url = str_replace(" ", "%20", $Course_Name);
            // Corrects The URL Data, removes spaces
            $Section_arr = file_get_contents("http://www.bkstr.com/webapp/wcs/stores/servlet/LocateCourseMaterialsServlet?requestType=SECTIONS&storeId={$StoreId}&programId={$ProgramID}&termId={$TermID}&divisionName={$Division_Name_url}&departmentName={$Department_Name_url}&courseName={$Course_Name_url}&_=");
            $Section_arr = str_replace("<script>parent.doneLoaded('", "", $Section_arr);
            $Section_arr = str_replace("')</script>", "", $Section_arr);
            $Section_arr = json_decode($Section_arr, true);
            $Section_arr = $Section_arr['data'][0];
            foreach ($Section_arr as $Section_Name => $Section_Value) {
                $Section_Name_url = str_replace(" ", "%20", $Section_Name);
                // $delay =  rand(3, 5);
                //                sleep($delay);
                $FinalUrl = "http://www.bkstr.com/webapp/wcs/stores/servlet/CourseMaterialsResultsView?catalogId=10001&categoryId=9604&storeId={$StoreId}&langId=-1&programId={$ProgramID}&termId={$TermID}&divisionDisplayName={$Division_Name_url}&departmentDisplayName={$Department_Name_url}&courseDisplayName={$Course_Name_url}&sectionDisplayName={$Section_Name_url}&demoKey=null&purpose=browse";
                $initial_csv_row_data = "Univ Of Illinois - Champaign,Spring 2010,{$Department_Name},{$Course_Name},{$Section_Name},{$FinalUrl}";
                MainBookData($FinalUrl, $initial_csv_row_data, $output);
                echo "\n";
                echo "Memory Usage  = " . memory_get_usage() / (1024 * 1024) . "MB  \n\n\n";
            }
            // Section
        }
        // Course
    }
    // Department
    fclose($output);
    //xdebug_stop_trace();
}
Esempio n. 3
0
function ProcessDataDigging_Generic($Store, $University_Name, $Campus_Name)
{
    if (PHP_OS == "WINNT") {
        $file_name = "c:\\{$University_Name}({$Campus_Name}).csv";
    } else {
        $file_name = "\\{$University_Name}({$Campus_Name}).csv";
    }
    $output = fopen($file_name, 'w');
    $row_data = "Program,Term,Department,Course,Section,Course URL,Book Title,BK Author,BK Edition,BK Image URL,BK Used Price,BK New Price,BK Digital Price,BK ISBN,Amazon List Price,Amazon Discount Price,Non Amazon New Price,Non Amazon Used Price,Amazon Detail Page URL,Detailed Link,Author(s),Edition,Publisher,ISBN (10),ISBN (13),ISBN (10) - Digi,ISBN (13) - Digi,List Price,You Pay Price\n";
    fwrite($output, $row_data);
    $Program_arr = file_get_contents("http://www.bkstr.com/webapp/wcs/stores/servlet/LocateCourseMaterialsServlet?requestType=INITIAL&storeId={$Store}&demoKey=d&_=");
    $Program_arr = str_replace("<script>parent.doneLoaded('", "", $Program_arr);
    $Program_arr = str_replace("')</script>", "", $Program_arr);
    $Program_arr = json_decode($Program_arr, true);
    $Program_arr = $Program_arr['data'][0];
    foreach ($Program_arr as $Program_Name => $Program_Value) {
        $Program_Name_url = str_replace(" ", "%20", $Program_Name);
        $term_arr = file_get_contents("http://www.bkstr.com/webapp/wcs/stores/servlet/LocateCourseMaterialsServlet?requestType=TERMS&storeId={$Store}&demoKey=d&programId={$Program_Value}&_=");
        $term_arr = str_replace("<script>parent.doneLoaded('", "", $term_arr);
        $term_arr = str_replace("')</script>", "", $term_arr);
        $term_arr = json_decode($term_arr, true);
        $term_arr = $term_arr['data'][0];
        foreach ($term_arr as $term_Name => $term_Value) {
            $term_arr = str_replace(" ", "%20", $term_Name);
            $Division_arr = file_get_contents("http://www.bkstr.com/webapp/wcs/stores/servlet/LocateCourseMaterialsServlet?requestType=DIVISIONS&storeId={$Store}&demoKey=d&programId={$Program_Value}&termId={$term_Value}&_=");
            $Division_arr = str_replace("<script>parent.doneLoaded('", "", $Division_arr);
            $Division_arr = str_replace("')</script>", "", $Division_arr);
            $Division_arr = json_decode($Division_arr, true);
            $Division_arr = $Division_arr['data'][0];
            if (!empty($Division_arr)) {
                foreach ($Division_arr as $Division_Name => $Division_Value) {
                    $Division_Name_url = str_replace(" ", "%20", $Division_Name);
                    // Corrects The URL Data, removes spaces
                    $Department_arr = file_get_contents("http://www.bkstr.com/webapp/wcs/stores/servlet/LocateCourseMaterialsServlet?requestType=DEPARTMENTS&storeId={$Store}&programId={$Program_Value}&termId={$term_Value}&divisionName={$Division_Name_url}&_=");
                    $Department_arr = str_replace("<script>parent.doneLoaded('", "", $Department_arr);
                    $Department_arr = str_replace("')</script>", "", $Department_arr);
                    $Department_arr = json_decode($Department_arr, true);
                    $Department_arr = $Department_arr['data'][0];
                    foreach ($Department_arr as $Department_Name => $Department_Value) {
                        $Department_Name_url = str_replace(" ", "%20", $Department_Name);
                        // Corrects The URL Data, removes spaces
                        $Course_arr = file_get_contents("http://www.bkstr.com/webapp/wcs/stores/servlet/LocateCourseMaterialsServlet?requestType=COURSES&storeId={$Store}&programId={$Program_Value}&termId={$term_Value}&divisionName={$Division_Name_url}&departmentName={$Department_Name_url}&_=");
                        $Course_arr = str_replace("<script>parent.doneLoaded('", "", $Course_arr);
                        $Course_arr = str_replace("')</script>", "", $Course_arr);
                        $Course_arr = json_decode($Course_arr, true);
                        $Course_arr = $Course_arr['data'][0];
                        foreach ($Course_arr as $Course_Name => $Course_Value) {
                            $Course_Name_url = str_replace(" ", "%20", $Course_Name);
                            // Corrects The URL Data, removes spaces
                            $Section_arr = file_get_contents("http://www.bkstr.com/webapp/wcs/stores/servlet/LocateCourseMaterialsServlet?requestType=SECTIONS&storeId={$Store}&programId={$Program_Value}&termId={$term_Value}&divisionName={$Division_Name_url}&departmentName={$Department_Name_url}&courseName={$Course_Name_url}&_=");
                            $Section_arr = str_replace("<script>parent.doneLoaded('", "", $Section_arr);
                            $Section_arr = str_replace("')</script>", "", $Section_arr);
                            $Section_arr = json_decode($Section_arr, true);
                            $Section_arr = $Section_arr['data'][0];
                            foreach ($Section_arr as $Section_Name => $Section_Value) {
                                $Section_Name_url = str_replace(" ", "%20", $Section_Name);
                                // $delay =  rand(3, 5);
                                //                sleep($delay);
                                $FinalUrl = "http://www.bkstr.com/webapp/wcs/stores/servlet/CourseMaterialsResultsView?catalogId=10001&categoryId=9604&storeId={$Store}&langId=-1&programId={$Program_Value}&termId={$term_Value}&divisionDisplayName={$Division_Name_url}&departmentDisplayName={$Department_Name_url}&courseDisplayName={$Course_Name_url}&sectionDisplayName={$Section_Name_url}&demoKey=null&purpose=browse";
                                $initial_csv_row_data = "{$Program_Name},{$term_Name},{$Division_Name},{$Department_Name},{$Course_Name},{$Section_Name},{$FinalUrl}";
                                MainBookData($FinalUrl, $initial_csv_row_data, $output);
                                echo "\n";
                                echo "Memory Usage  = " . memory_get_usage() / (1024 * 1024) . "MB  \n\n\n";
                            }
                            // Section
                        }
                        // Course
                    }
                    // Department
                }
            } else {
                $Division_Name = " ";
                $Division_Name_url = str_replace(" ", "%20", $Division_Name);
                // Corrects The URL Data, removes spaces
                $Department_arr = file_get_contents("http://www.bkstr.com/webapp/wcs/stores/servlet/LocateCourseMaterialsServlet?requestType=DEPARTMENTS&storeId={$Store}&programId={$Program_Value}&termId={$term_Value}&divisionName={$Division_Name_url}&_=");
                $Department_arr = str_replace("<script>parent.doneLoaded('", "", $Department_arr);
                $Department_arr = str_replace("')</script>", "", $Department_arr);
                $Department_arr = json_decode($Department_arr, true);
                $Department_arr = $Department_arr['data'][0];
                foreach ($Department_arr as $Department_Name => $Department_Value) {
                    $Department_Name_url = str_replace(" ", "%20", $Department_Name);
                    // Corrects The URL Data, removes spaces
                    $Course_arr = file_get_contents("http://www.bkstr.com/webapp/wcs/stores/servlet/LocateCourseMaterialsServlet?requestType=COURSES&storeId={$Store}&programId={$Program_Value}&termId={$term_Value}&divisionName={$Division_Name_url}&departmentName={$Department_Name_url}&_=");
                    $Course_arr = str_replace("<script>parent.doneLoaded('", "", $Course_arr);
                    $Course_arr = str_replace("')</script>", "", $Course_arr);
                    $Course_arr = json_decode($Course_arr, true);
                    $Course_arr = $Course_arr['data'][0];
                    foreach ($Course_arr as $Course_Name => $Course_Value) {
                        $Course_Name_url = str_replace(" ", "%20", $Course_Name);
                        // Corrects The URL Data, removes spaces
                        $Section_arr = file_get_contents("http://www.bkstr.com/webapp/wcs/stores/servlet/LocateCourseMaterialsServlet?requestType=SECTIONS&storeId={$Store}&programId={$Program_Value}&termId={$term_Value}&divisionName={$Division_Name_url}&departmentName={$Department_Name_url}&courseName={$Course_Name_url}&_=");
                        $Section_arr = str_replace("<script>parent.doneLoaded('", "", $Section_arr);
                        $Section_arr = str_replace("')</script>", "", $Section_arr);
                        $Section_arr = json_decode($Section_arr, true);
                        $Section_arr = $Section_arr['data'][0];
                        foreach ($Section_arr as $Section_Name => $Section_Value) {
                            $Section_Name_url = str_replace(" ", "%20", $Section_Name);
                            // $delay =  rand(3, 5);
                            //                sleep($delay);
                            $FinalUrl = "http://www.bkstr.com/webapp/wcs/stores/servlet/CourseMaterialsResultsView?catalogId=10001&categoryId=9604&storeId={$Store}&langId=-1&programId={$Program_Value}&termId={$term_Value}&divisionDisplayName={$Division_Name_url}&departmentDisplayName={$Department_Name_url}&courseDisplayName={$Course_Name_url}&sectionDisplayName={$Section_Name_url}&demoKey=null&purpose=browse";
                            $initial_csv_row_data = "{$Program_Name},{$term_Name},Spring 2010,{$Department_Name},{$Course_Name},{$Section_Name},{$FinalUrl}";
                            MainBookData($FinalUrl, $initial_csv_row_data, $output);
                            echo "\n";
                            echo "Memory Usage  = " . memory_get_usage() / (1024 * 1024) . "MB  \n\n\n";
                        }
                        // Section
                    }
                    // Course
                }
                // Department
            }
            // ELSE to check If Division is Zero
        }
    }
    fclose($output);
}