Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple dom problem

Status
Not open for further replies.

someoneneedshelps

Technical User
Mar 3, 2016
75
GB
Im search some html for the £4.50 out of this...

Code:
<span id="fshippingCost" class="notranslate sh-cst "><span>£4.50</span>

using this code
Code:
	foreach($html->find('span[id=fshippingCost]') as $shippingcost)
	{
		$arrayresults[] = $shippingcost->plaintext;
		$shippingcoststr = $shippingcost->plaintext;
	}

strangest result back is £17.33 why???
 
You could do that, but the shipping cost ebay displays to each user depends on auction source country and bidder destination country, so it varies.
Who are your users? Auctioners or Bidders?

Bye, Olaf.
 
bidders have a control panel that allows them to place ebay url and it imports everything into another bidding site saving time copying pasting etc

... is it possible to use fragments of the api to replace simple dom? ...is loadhtml for php any better that simple dom or they similar
 
 Ts
A bidder is making bids, he's not the owner of the product, so I think you mean auctioners are copying their auctions to other sites. That obviously has the prerequisite it's not the auction of a single item, but since eBay rather has become a shopping mile anyway, that's perhaps not the problem.

I don't know how to exactly answer your question about API vs dom parser, as they don't compare at all. The intention of any API (application programming interface) is to have an open interface where eBay itself interfaces to it's data, but also further applications can extend eBay.

The API is a programming interface answering your questions via methods foreseen to give the detail infos you need in a better quality than you can scrape off, but the approach totally differs from scraping information. With allowance of users, the API even enables starting auctions, changing auctions, everything you might do on the behalf of the eBay user. The API methods are official, directly "wired" to eBays database, so they give concrete infos as eBay stores in their backend(s) to put together the auctions HTML themselves.

Via the API you go directly at what you need (and what eBay offers). I don't think you can get any detail from scraping an auctions HTML, which you can't get from the API. The limit of 500 will hit you with a few users, so you would need to make your application apply to the rules specified, for example about OWASP safety guidance. It's not at all a bad idea to apply these rules to any web application anyway (
Bye, Olaf.
 
Hi can I possibly see a very simple call with the api pulling a bit data out by item number please? I have registered but not a clue where to start
 
below is sample code, but all I want is what I did above, the result of what im searching for, how can I do this with below and break it down to look for lets say, the shipping cost..

Code:
<html>
<head>
<title>eBay Search Results</title>
<style type="text/css">body { font-family: arial,sans-serif;} </style>
</head> 
<body>
<h1>eBay Search Results</h1>
<div id="results"></div>

<script>
function _cb_findItemsByKeywords(root)
{
  var items = root.findItemsByKeywordsResponse[0].searchResult[0].item || [];
  var html = [];
  html.push('<table width="100%" border="0" cellspacing="0" cellpadding="3"><tbody>');

  for (var i = 0; i < items.length; ++i)  
  {
    var item     = items[i];
    var title    = item.title;
    var pic      = item.galleryURL;
    var viewitem = item.viewItemURL;

    if (null != title && null != viewitem)
    {
      html.push('<tr><td>' + '<img src="' + pic + '" border="0">' + '</td>' + 
        '<td><a href="' + viewitem + '" target="_blank">' + title + '</a></td></tr>');
    }
  }
  html.push('</tbody></table>');
  document.getElementById("results").innerHTML = html.join("");
}
</script>


<script src=[URL unfurl="true"]http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=XXXXX&OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&callback=_cb_findItemsByKeywords&REST-PAYLOAD&keywords=iphone%203g&paginationInput.entriesPerPage=3>[/URL]
</script>
</body>
</html>
 
the tutorial is not clear at all with parsing the data, it gives a result back for a keyword search, that's not what I want
 
You don't get the gist of this.

The code you show is not only making a call, it's also processing the response. It's a full example.
Focus on this line:

Code:
<script src=[URL unfurl="true"]http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=XXXXX&OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&callback=_cb_findItemsByKeywords&REST-PAYLOAD&keywords=iphone%203g&paginationInput.entriesPerPage=3>[/URL]
</script>

And the core of that aside of the callbasck is not only doable in Javascript, it's a http request of:
Code:
[URL unfurl="true"]http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=XXXXX&OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD&keywords=iphone%203g&paginationInput.entriesPerPage=3[/URL]

What other Service APIs are available and what methods they offer is within the reference of all the APIs, what parameters you pass in and what response you get out is described there.
You won't make me read for you. Now is reading time, take a tour, get an overview, look at what you want.

Bye, Olaf.
 
Now I get it... next question, where do my credentials get entered above? my file is on my server so I need to to knock on the door and let ebay let me in for data
 
Well, your PHP will do the service calls, so these urls will never be seen by clients. As with any credentials, eg as with MySQL credentialy, you put them in some config.php you include/require and then use the URLs via PHPs cURL integration.
Or do this as ebay demonstrates for PHP: I'd not work with globals, but that aside look how they compose the URL call and then use simplexml_load_file($apicalla) to make the call and load the response xml and how you get at the inner data via the result $resp object.

You will need to change from asking an auction URL to asking the users ebay account and let him allow your api account to query in his auctions. You let him pick from the list of his auctions and then can get any info about the picked auction.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top