ukscotth
-
Posts
195 -
Joined
-
Last visited
Posts posted by ukscotth
-
-
Shouldnt the echo $n->nodeValue."\n"; part already echo something out ?
Sorry if im being stoopid.
-
Sorry not sure how that @ got there.
It just shows a blank page when i run it
-
Hi,
Im having a nightmare trying to scrape some data from the freelancer.com website. I only need to scrape the job titles but for some reason it isnt working.
usually I would just do something like this :
$html = new DOMDocument(); @$html->loadHtmlFile('http://www.freelancer.com/sellers/'); $xpath = new DOMXPath( $html ); $nodelist = $xpath->query( "//div[@class='title']" ); foreach ($nodelist as $n){ echo $n->nodeValue."\n"; echo '<br>'; }
Its just showing blank results.
Any ideas ?
-
Perfect. Thankyou
-
Hi all,
Is there an easy way to check to see if a string only contains letters and numbers ?
Thanks in advance,
Scott.
-
Hi,
i have this piece of code which scrapes data from a website and it works great. I want to also grab all the additional images that are in the div but I'm not very good with arrays etc and I'm a bit stuck.
Any ideas ?
Thanks in advance,
Scott
GrabHTML($car_link); $links = $xpath->query( "//div[@id='contents']" ); $return = array(); foreach ( $links as $item ) { $newDom = new DOMDocument; $newDom->appendChild($newDom->importNode($item,true)); $xpath = new DOMXPath( $newDom ); $car_title = trim($xpath->query("//div[@class='rubrik']") ->item(0)->nodeValue); $car_year = trim($xpath ->query("//div[@class='infoRow'][1]") ->item(0)->nodeValue); $car_color = trim($xpath ->query("//div[@class='infoRowAlternate'][1]") ->item(0)->nodeValue); $car_milage = trim($xpath ->query("//div[@class='infoRow'][2]") ->item(0)->nodeValue); $car_price = trim($xpath ->query("//div[@class='infoRowAlternate'][2]") ->item(0)->nodeValue); $car_seller = trim($xpath ->query("//div[@class='infoRow'][3]") ->item(0)->nodeValue); $car_desc = trim($xpath ->query("//div[@class='infoRowAlternate'][3]") ->item(0)->nodeValue); $car_desc2 = trim($xpath ->query("//div[@class='infoRow'][4]") ->item(0)->nodeValue); $car_image = trim($xpath ->query("//img[1]/@src") ->item(0)->nodeValue); }
-
Thanks alot for your help you 2
I tried the var_dump and it showed me that the string was 6 characters " $0.00" so it was the first blank character that was causing me the problems.
Thanks again for your help. Problem solved
-
that part isnt in the if part though is it ? if you look I added == in the actual if part
-
Hi,
Im trying to use an IF ststement in a piece of code but it doesnt seem to be working, please can you help.
Heres the IF ststement :
$price2 = wpsc_the_product_price(); if ($price2 == "$0.00"){echo "Request Quote";}
and heres the wpsc_the_product_price() function :
function wpsc_the_product_price( $no_decimals = false ) { global $wpsc_query, $wpsc_variations, $wpdb; if ( isset($wpsc_variations->first_variations) && count( $wpsc_variations->first_variations ) > 0 ) { //select the variation ID with lowest price $output = wpsc_product_variation_price_available(get_the_ID()); $from = ' from '; } else { $product_id = get_the_ID(); $from = ''; $full_price = get_post_meta( $product_id, '_wpsc_price', true ); $special_price = get_post_meta( $product_id, '_wpsc_special_price', true ); $price = $full_price; if ( ($full_price > $special_price) && ($special_price > 0) ) $price = $special_price; if ( $no_decimals == true ) $price = array_shift( explode( ".", $price ) ); $args = array( 'display_as_html' => false, 'display_decimal_point' => !$no_decimals ); $output = wpsc_currency_display( $price,$args ); } //if product has variations - add 'from' $from = apply_filters('wpsc_product_variation_text',$from); if ( isset($wpsc_variations->first_variations) && count( $wpsc_variations->first_variations ) > 0 && !empty($from)) $output = sprintf(__(' from %s', 'wpsc'), $output); return $output; } function wpsc_calculate_price( $product_id, $variations = null, $special = true ) { global $wpdb; $p_id = $product_id; if ( count( $variations ) > 0 ){ if(!isset($variations) || is_array($variations) && in_array(0,$variations,true)) return; $product_id = wpsc_get_child_object_in_terms( $product_id, $variations, 'wpsc-variation' ); }else if ( !$product_id ) $product_id = get_the_ID(); if( !$product_id && count( $variations ) > 0){ $product_ids = wpsc_get_child_object_in_select_terms( $p_id, $variations, 'wpsc_variation' ); $sql = "SELECT `post_id` FROM ".$wpdb->postmeta." WHERE `meta_key` = '_wpsc_stock' AND `meta_value` != '0' AND `post_id` IN (".implode(',' , $product_ids).")"; $stock_available = $wpdb->get_col($sql); $sql = "SELECT `post_id` FROM ".$wpdb->postmeta." WHERE `meta_key` = '_wpsc_price' AND `post_id` IN (".implode(',',$stock_available).") ORDER BY `meta_value` ASC LIMIT 1"; $product_id = $wpdb->get_var($sql); } if ( $special ) { $full_price = get_post_meta( $product_id, '_wpsc_price', true ); $special_price = get_post_meta( $product_id, '_wpsc_special_price', true ); $price = $full_price; if ( ($full_price > $special_price) && ($special_price > 0) ) { $price = $special_price; } } else { $price = get_post_meta( $product_id, '_wpsc_price', true ); } return $price; }
If I echo wpsc_the_product_price() it comes up as $0.00 but when I try and use IF with it it doesnt seem to work.
Please shelp its driving me mad
-
Ok it came up with this error :
Warning: DOMDocument::loadHTMLFile() [function.DOMDocument-loadHTMLFile]: URL file-access is disabled in the server configuration in /var/www/vhosts/merchandizeliquidators.com/httpdocs/scraper.php on line 35 Warning: DOMDocument::loadHTMLFile(http://www.merchandizeliquidators.com/category/10/Bed_and_Bath.html?size=1000) [function.DOMDocument-loadHTMLFile]: failed to open stream: no suitable wrapper could be found in /var/www/vhosts/merchandizeliquidators.com/httpdocs/scraper.php on line 35
-
Thanks wizard. He seems to of vanished at the moment but as soon as hes back Il get him to give it a try.
Thanks again.
-
Hi all,
I've writen a piece of code for a client which basically scarpes data, it works fine on my server but when we upload it to his it displays a blank page
Any ideas ?
Heres the code :
<?php // START OF SITE SCRAPING CODE // Scrape the Data $oldSetting = libxml_use_internal_errors( true ); libxml_clear_errors(); $html = new DOMDocument(); $html->loadHtmlFile( 'http://www.merchandizeliquidators.com/category/10/Bed_and_Bath.html?size=1000'); $xpath = new DOMXPath( $html ); $links = $xpath->query( "//table[@class='thumbnail_item']" ); $return = array(); foreach ( $links as $item ) { $newDom = new DOMDocument; $newDom->appendChild($newDom->importNode($item,true)); $xpath = new DOMXPath( $newDom ); $image_url = trim($xpath->query("//img [@class='thumbnail_image']/@src") ->item(0)->nodeValue); $item_url = trim($xpath ->query("//a[@class='thumbnail_item_name']/@href") ->item(0)->nodeValue); $item_title = trim($xpath ->query("//a[@class='thumbnail_item_name']") ->item(0)->nodeValue); $item_desc = trim($xpath ->query("//div[@class='thumbnail_item_desc']") ->item(0)->nodeValue); $item_price = trim($xpath ->query("//td[@class='price']") ->item(0)->nodeValue); $image_url = 'http://www.merchandizeliquidators.com'.$image_url; $item_url = 'http://www.merchandizeliquidators.com'.$item_url; // Display the Data ?> <table width="450px" border="0" cellpadding="5" align="center"> <tr> <td width="14%" valign="top"> <a href="<?php echo $item_url;?>"><img src="<?php echo $image_url;?>" width="100" height="100" border="0"/></a> </td> <td width="86%" valign="top"> <?php echo '<h2><a href="'.$item_url.'">'.$item_title.'</a></h2>';?> <?php echo '<p>'.$item_desc.'</p>';?> <?php echo '<p>Price: '.$item_price.'</p>';?> <a href="<?php echo $item_url;?>"> <img src="http://cellphoneconnect.co.uk/store/includes/templates/RI_TEMPLATE_07/buttons/english/button_more_info.gif" border ="0"/> </a> <hr /> </tr> </table> <?php } libxml_clear_errors(); libxml_use_internal_errors( $oldSetting ); // END OF SITE SCRAPING CODE ?>
-
solved. Thanks.
-
Hi,
I'm trying to learn how to scrape data using php. I can get the data I need with the following code but I dont know how to split it up into parts so I can style the output. I basically want the title, description etc as seperate variables. Any ideas ?
<?php $html = new DOMDocument(); @$html->loadHtmlFile('http://www.merchandizeliquidators.com/category/10/Bed_and_Bath.html?size=1000'); $xpath = new DOMXPath( $html ); $nodelist = $xpath->query(" //img [@class='thumbnail_image']/@src | //a[@class='thumbnail_item_name'] | //div[@class='thumbnail_item_desc'] | //td[@class='price']"); foreach ($nodelist as $n){ echo $n->nodeValue."\n"; echo '<br><br>'; } ?>
Many thanks,
Scott.
-
Seems to work great. Sorry for being stupid but will this return posts from today or posts from this week ?
$sql = 'SELECT * FROM `submittedtexts` WHERE approved = 1 AND `date` > DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY) Order by id DESC LIMIT '. (($page - 1) * 6) .', 6';
-
Excellent. Thanks so much, il give it a try when i get back on the main pc
-
The host wont help him at all, its a bit of a rubbish service he's using but he seems to like it lol.
But thanks very much for your help its working great now, its most appreciated
-
That looks great. I only have access to the body, would it matter if I put all the code from that site into the body instead of the head ?
-
thanks very much for the replies and sorry for the slow reply.
That looks great but instead of grabbing the last 7 days I need it to grab data from this week so it would be all posts since Monday. If that makes sense.
Would that be easy to do ?
Thanks again.
Scott
-
Problem is all the javascript methods i have seen require SSI
-
Thanks but its a shopping type adult site that is all managed by the host so he wouldnt be able to simply move it unfortunatly.
-
he doesnt have ftp access unfortunatly
-
Hi,
Doesnt matter if its not 100% secure.
-
Hi,
Is there any way to get a users ip without using SSI or PHP ?
I am trying to add a ban ip feature to a friends site but he only has access to an admin panel and can only edit the body part of his html page.
Ive been googling for hours now and cant find a way
Can anyone help ?
Many thanks,
Scott
Page too wide problem
in CSS Help
Posted
Hi all,
Im having an annoying problem. There is a big grey block down the right hand side of this website and I cant get rid of it. http://www.impact25.com/biovive/
Heres the index file code :
and heres the css :
Please can someone tell me how i can get rid of it, its driving me mad
Many thanks,
Scott