Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include 'simple_html_dom.php';
- $partlist_file = $_SERVER['DOCUMENT_ROOT'].'/partlist.txt';
- $partlist = file('knn-partnumberlist.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
- $stock = '';
- $output_first = '';
- foreach($partlist as $parts => $part) {
- $html = file_get_html('search/product.aspx?prod=' . $part);
- $ret = $html->find('span#cph_lb_stock_buy');
- foreach($ret as $element) {
- $stock = $element->plaintext;
- $stock = preg_replace(array('/\n/','/\r/'),'',$stock);
- $stock = trim($stock);
- if($stock == 'Not in stock.') {
- $stock = '0';
- } elseif($stock == 'In Stock & Ready to Ship!') {
- $stock = '6';
- }
- $output = 'K33' . $part . ',' . $stock . "n";
- print_r ($output); // returns all elements
- file_put_contents($partlist_file, $output); // only returns last element
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement