Visa ett inlägg
Oläst 2012-07-28, 12:37 #3
jonssondesign jonssondesign är inte uppkopplad
Mycket flitig postare
 
Reg.datum: Oct 2010
Inlägg: 709
jonssondesign jonssondesign är inte uppkopplad
Mycket flitig postare
 
Reg.datum: Oct 2010
Inlägg: 709
Smart, men fungerade inte riktigt..hm

Får felmeddelande:
Warning: file_get_contents(http%3A%2F%2Fnelly.com%2Fse%2Fkl %C3%A4der-f%C3%B6r-kvinnor%2Fsportkl%C3%A4der%2Ftr%C3%B6jor%2Froxy-169%2Fbeach-brights-zipper-169086-54%2F) [function.file-get-contents]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\reaplagg\admin\includes\simple_ html_dom.php on line 70

Fatal error: Call to a member function find() on a non-object in C:\Program Files\xampp\htdocs\reaplagg\admin\includes\functio ns.php on line 109
Det verkar fungera bra om jag skriver url'en manuellt. såhär:

echo getOrgPrice('http://nelly.com/se/kläder-för-kvinnor/sportkläder/sport-bh/filippa-k-soft-sport-2123/yoga-bra-top-676373-99/');

Men så fort jag använder en variabel istället för klartext så fungerar det inte :S

såhär ser det ut med en variabel:

echo getOrgPrice($new_url);


Använder jag urlencode() runt $real_url och lägger in det i $new_url så blir det felmeddelande.
Använder jag $real_url direkt i funktionen istället för $new_url, så händer ingenting.. Inga felmeddelanden, men inga siffror syns heller.. hm.

Såhär ser min funktion ut:

PHP-kod:
include_once('includes/simple_html_dom.php');
function 
getOrgPrice($url) {

    
$original_url  $url;
    
$delete_url = array("å","ä""ö");
    
$replace_url   = array("%C3%A5""%C3%A4""%C3%B6");
    
$new_url str_replace($delete_url$replace_url$original_url);
    
    
$html file_get_html($new_url);
                        
    
$ret $html->find('p[class=productOverview_items_content_itemlist_item_reaprice_price] span');
                           
    foreach(
$ret as $k=>$v) {
                           
        
$original_string  $v;
        
$delete_string = array("<span style=\"text-decoration:line-through;\">SEK ","</span>");
        
$replace_with   = array("""");
        
$new_string str_replace($delete_string$replace_with$original_string);
                                   
        return 
$new_string;
    };

jonssondesign är inte uppkopplad   Svara med citatSvara med citat