【问题标题】:get the steam market lowest prices?拿到steam市场最低价?
【发布时间】:2015-04-17 10:36:01
【问题描述】:

我在 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);
?>

【问题讨论】:

  • 您想将 PHP 代码应用到 ASP.NET 网站吗?
  • 是的,我想在 asp.net 网站@TZHX 上完成这项工作
  • PHP代码你看懂了吗?
  • 不,我是编码新手@TZHX
  • 然后去阅读关于 ASP.NET MVC 的教程。 Stack Overflow 不是为了帮助你学习编程,而是为了解决具体的编程问题。 “如何执行 HTTP 请求、解析 HTML 并从中获取有意义的值”并不具体,而是过于宽泛。

标签: asp.net-mvc steam


【解决方案1】:

类似的东西:

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

【讨论】:

  • thx 我会试试这个,它对我来说更有意义,它看起来像一个
猜你喜欢
  • 2015-11-04
  • 2020-09-15
  • 2017-09-09
  • 1970-01-01
  • 2016-02-21
  • 2016-03-12
  • 2015-07-06
  • 2015-01-21
  • 1970-01-01
相关资源
最近更新 更多