获得蒸汽市场最低价格?

时间:2015-04-17 10:36:01

标签: asp.net-mvc steam

我在stackoverflow.com上搜索我的问题,我发现这个答案与我有关。问题是我不知道如何将这些代码应用到我的asp.net mvc网站

<?php
$string = file_get_contents('http://steamcommunity.com/market/listings/730/AK-47%20|%20Vulcan%20%28Battle-Scarred%29');
$attrList = explode('<span class="market_listing_price market_listing_price_with_fee">',$string);
$N=count($attrList);
for ($i=1;$i<$N;$i++){
    $prices[$i-1] = explode('</span>',$attrList[$i])[0];
}
print_r($prices);
?>

1 个答案:

答案 0 :(得分:0)

有些事情:

var wc = new WebClient();
var pageAsString = wc.DownloadString(new Uri("http://steamcommunity.com/market/listings/730/AK-47%20|%20Vulcan%20%28Battle-Scarred%29"));

var attrList = pageAsString.Split(new string[] { "<span class=\"market_listing_price market_listing_price_with_fee\">"}, StringSplitOptions.RemoveEmptyEntries);

var prices = new List<string>();

for (var i = 1; i < attrList.Count(); i++)
{
    prices.Add(attrList[i].Split(new string[] { "</span>" }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault().Trim());
}

// Do something with prices variable