2015-04-17 137 views
-5

我搜索stackoverflow.com我的問題,我發現這個答案與mine.the問題是我不知道如何驗證碼沿應用到我的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); 
?> 
+2

您想將PHP代碼應用到ASP.NET網站嗎? – TZHX

+0

是的,我想在asp.net網站上進行這項工作@TZHX – fgocken

+0

您瞭解PHP代碼嗎? – TZHX

回答

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 
+0

thx我會嘗試這個東西與這個,它對我來說更有意義,它看起來像一個