['link'] ) : null; if(empty($html)){ continue; } $id = $url['id']; // $html = file_get_contents('bookmarks.html'); //Create a new DOM document $dom = new DOMDocument; //Parse the HTML. The @ is used to suppress any parsing errors //that will be thrown if the $html string isn't valid XHTML. @$dom->loadHTML($html); //Get all links. You could also use any other tag name here, //like 'img' or 'table', to extract other tags. $links = $dom->getElementsByTagName('a'); //Iterate over the extracted links and display their URLs $title = $dom->getElementsByTagName('title'); foreach( $title as $product_name ) { $name = str_replace( ' | Prijzen vergelijken', '', $product_name->nodeValue ); $name = str_replace( ' | Kieskeurig.nl', '', $name ); } $price_comparison[$i]['id'] = $id; $price_comparison[$i]['Product'] = $url['product']; $price_comparison[$i]['name'] = $name; $price_comparison[$i]['date'] = current_time('d-m-Y H:i:s'); foreach ( $links as $link ){ $shop = substr( $link->getAttribute('data-shop'), 2, -1 ); $price = substr( $link->getAttribute('data-product-price'), 2, -1 ); if ( !empty($shop) && !isset($price_comparison[$i][$shop]) ) { $price_comparison[$i][$shop] = $price; } } } return $price_comparison; } function price_compare_urls() { ini_set('memory_limit', '2048M'); ini_set('max_input_time', 7200); ini_set('max_execution_time', 7200); ini_set('post_max_size', '4G'); ini_set('upload_max_filesize', '2G'); $k = 0; $links = array(); $products = get_posts(array( 'numberposts' => -1, 'post_type' => 'product', 'meta_key' => 'kkprijscheck', 'meta_value' => 'yes', 'orderby' => 'title', 'order' => 'ASC' )); foreach($products as $i => $product ){ $id = $product->ID; $url = get_post_meta($id, 'kkurl', true); $title = get_the_title( $id ); //if ( $url > NULL ) { $links[$k] = array ( 'link' => $url, 'product' => $title, 'id' => $id ); $k++; //} } return $links; } function zoek_automatisch_kieskeurig_url_via_eancode(){ ini_set('memory_limit', '1024M'); ini_set('max_input_time', 7200); ini_set('max_execution_time', 7200); ini_set('post_max_size', '4G'); ini_set('upload_max_filesize', '2G'); $products = price_compare_urls(); $i = 0; foreach($products as $p => $_product){ if(empty($_product['link']) && !empty(get_post_meta($_product['id'], 'kkeancode', true))){ $id = null; $links = array(); $name = null; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://www.kieskeurig.nl/search?q='.get_post_meta($_product['id'], 'kkeancode', true)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCAT Vergelijking - Ringfoto Meppel