Froodle
Froodle

Reputation: 349

c# obtaining data from a website

I am currently obtaining data from ebay.co.uk searches using this URL,

_url = "http://www.ebay.co.uk/sch/i.html?_sacat=0&_from=R40&_nkw=" +ItemName.Text +"&_sop=15";

i download the html of it then then do many string splits until I get to the data I require, example:

_itemImage[i - 1] = codes.StringGetter("<img  src=\"", "\" class=\"img\" alt='", items[i], 1);
// or a worse example
_itemPrice[i - 1] = codes.StringGetter("<div  class=\"g-b\" itemprop=\"price\">\n\t\t\t\t\tÂ", "</div>\n\t\t\t\t<div class=\"bin\">", items[i], 1);

//the function stringGetter is just 
text = StringSplit(StringSplit(totalString, start)[number], end)[0]; 
//StringSplit is just a split with any string accepted

Is there a better way of doing this as it seems long winded and if the html layout changes my program will no longer work.

Upvotes: 0

Views: 102

Answers (2)

Durai
Durai

Reputation: 582

Did you check the eBay API ?

The following is the link to eBay's API. I think you can use this API to achieve the search functionality.

https://go.developer.ebay.com/developers/ebay/documentation-tools/sdks/dotnet

Seems you can use this API to get the item details http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetItem.html

Upvotes: 2

Shiva
Shiva

Reputation: 20935

That's why eBay has an API. Here's the Finding API: https://go.developer.ebay.com/developers/ebay/products/finding-api

Specifically, you can use the FindProducts to search for Products. http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindProducts.html

Upvotes: 2

Related Questions