Я пытаюсь использовать HTML Agility Pack, чтобы потянуть цену/состояние/судно ... вот URL, который я считываю: http://www.amazon.com/gp/offer-listing/ ... dition=all
Here's a snippet of my code:
Код: Выделить всё
string results = "";
var w = new HtmlWeb();
var doc = w.Load(url);
var nodes = doc.DocumentNode.SelectNodes("//div[@class='a-row a-spacing-medium olpOffer']");
if (nodes != null)
{
foreach (HtmlNode item in nodes)
{
var price = item.SelectSingleNode(".//span[@class='a-size-large a-color-price olpOfferPrice a-text-bold']").InnerText;
var condition = item.SelectSingleNode(".//h3[@class='a-spacing-small olpCondition']").InnerText;
var price_shipping = item.SelectSingleNode("//span[@class='olpShippingPrice']").InnerText;
results += "price " + price + " condition " + condition + " ship " + price_shipping + "\r\n";
}
}
return results;
Обновление < /p>
Решено. Я удалил «.InnerText» из Price_shipping, что вызывает проблемы, когда это было ноль ... затем я сделал нулевую проверку, а затем было безопасно использовать .innerText.
Подробнее здесь: https://stackoverflow.com/questions/181 ... ath-syntax
Мобильная версия