Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8372601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:28:28+00:00 2026-06-09T14:28:28+00:00

I previously found a script while googling and used it for scrapping purpose, my

  • 0

I previously found a script while googling and used it for scrapping purpose, my main class

in my amazon.php, I wrote the following script

include('scrape.php');
set_time_limit(0);


$ASIN       =   'B000GEM3RI';
$shipArray  =   shipingPrice($ASIN);
var_dump($shipArray);
print_r($shipArray);
echo $shipArray;



function shipingPrice($city){
        $shipArray = array();
        $scrape = new Scrape();
        $url = 'http://www.amazon.com/gp/offer-listing/'.$city.'/ref=dp_olp_new?ie=UTF8&condition=new';
        $scrape->fetch($url);
        $data = $scrape->removeNewlines($scrape->result);
        $data = $scrape->fetchBetween('<table cellspacing="0" cellpadding="0" width="100%" border="0"> <thead class="columnheader"><tr><th scope="col" class="price">Price + Shipping</th><th scope="col" class="condition">Condition</th><th scope="col" class="seller">Seller Information</th><th scope="col" class="readytobuy">Buying Options</th></tr></thead>','</table>',$data,true); 
        $rows = $scrape->fetchAllBetween('<tr','</tr>',$data,true);
        $i=0;$j=0;
        foreach ($rows as  $row){
            if($i!=0){
                if($i!=2){              
                    $record = array();
                    $cells = $scrape->fetchAllBetween('<td','</td>',$row,true);                 
                    $record['price'] = strip_tags($cells[0]);
                    
                    if(stristr($record['price'],'oz')===False && stristr($record['price'],'/')===False)
                    {
                        $listPrice=$scrape->fetchBetween('$',' +',$record['price']);
                    }else{
                        $listPrice=$scrape->fetchBetween('$',' (',$record['price']);
                    }
                    //print_r($listPrice);
                    if($listPrice==''){
                        $listPrice=$scrape->fetchBetween('$',' &',$record['price']);
                        $shipPrice='0';                     
                    }else{
                        $shipPrice=$scrape->fetchBetween('+ $','s',$record['price']);
                    }
                    $shipPrice= floatval($shipPrice);
                    //####                  
                    $sellerIdInfo = $cells[2];                                          $sellerIdArray=$scrape->fetchAllBetween('&marketplaceSeller=0&seller=','"><b>',$sellerIdInfo);                  
                    if(count($sellerIdArray)>1){
                        $sellerId=$sellerIdArray[0];
                    }else{
                        $temp = explode('"id',$sellerIdArray[0]);
                        $sellerId=$temp[0];                                         
                    }
                    //##
                    $sellerName =$scrape->fetchBetween('Seller:','Seller',$record['price']);                    
                    $sellerInfo=$scrape->fetchAllBetween('alt="','"',$cells[2],true);           
                    $sellerName=str_replace(array('alt="','"'),array('',''),$sellerInfo[0]);
                    if($sellerName!=""){        
                        //
                    }else{
                        $sellerName = $scrape->fetchBetween('<span class="sellerHeader">Seller:</span>','</b></a>',$cells[2],true);
                        $sellerName=str_replace("Seller:","",$sellerName);
                        $sellerName=$scrape->fetchBetween('<b>','</b>',$sellerName);            
                    }

                    array_push($shipArray,array('sellerName'=>$sellerName,'sellerId'=>$sellerId,'price'=>$listPrice,'shipPrice'=>$shipPrice));

                }
            }
            $i++;
        }
        return $shipArray;
}

the url for this scrip is amazon

when I echo it, var_dump it or print_r, an empty array is displayed, I checked the page using firebug and to me, looks like everything is okay in my code

can somebody tell me why I can access anything from the page although my code is okay?

thanks for helping me

EDIT:-

By adding return $this->result = curl_exec($ch); in my scrap class function fetch($url), I have assured that Page is being retrieved successfullly…

EDIT-2:-

after working on the advice as provided in answer, it tried

$shipArray[]=array('sellerName'=>$sellerName,'sellerId'=>$sellerId,'price'=>$listPrice,'shipPrice'=>$shipPrice); 

in my function, but still the same empty array

EDIT-3

I changed the following function

function fetchBetween($needle1,$needle2,$haystack,$include=false){
        
        $position = strpos($haystack,$needle1);
        
        if ($position === false) { return ' it was null data'; }

when I echo echo $data; in my script file,

it was null data

is printed, so looks like this line of code $position = strpos($haystack,$needle1); is not working,

am I right?

if yes, what to do now?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:28:29+00:00Added an answer on June 9, 2026 at 2:28 pm

    Gotcha, I was correct, issue was not with my code

    on line

     $data = $scrape->fetchBetween('<table cellspacing="0" cellpadding="0" width="100%" border="0"> <thead class="columnheader"><tr><th scope="col" class="price">Price + Shipping</th><th scope="col" class="condition">Condition</th><th scope="col" class="seller">Seller Information</th><th scope="col" class="readytobuy">Buying Options</th></tr></thead>','</table>',$data,true);
    

    there was an extra space border="0"> <thead class, that was creating issue, once, I removed this the space from

    <table cellspacing="0" cellpadding="0" width="100%" border="0"><thead class="columnheader">
    

    my code became okay..

    thanks to everyone

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a shell script, I found the following line of code: rm -f ${Tmp0}
Previously I did a Tutorial on OpenGL-ES 1.0. For reference, this can be found
I've looked at the previously-posted jQuery/MVC questions and haven't found a workable answer. I
i faced a problem while replaying a script created for yahoomail page.The XPath statement
What does isset($_SESSION) mean? I found the following code snippet- if (!isset($_SESSION)) { //
(I'm using Joomla v1.5.15 and PHP 5.3.4) I have tested the solutions found in
I have made an each statement which iterates through each class item found. At
We are updating our codebase to use the namespace functionality provided in PHP-5.3+ Previously,
I have been doing some customization to this jQuery paging script I found here
I've done a lot of Googling, but haven't found anything, so I'm really sorry

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.