我找不到在这个范围内获取值的方法:
<span class="market_listing_price market_listing_price_with_fee">
$0.15 USD </span>
我试过这个:
Regex regex = new Regex(@"<span class=""market_listing_price market_listing_price_with_fee"">(.*?)</span>");
Match match = regex.Match(result);
string result = match.Groups[1].Value;
但可能它不匹配制表符或符号...
请您参考如下方法:
我同意以上评论,您最好使用 html agility pack .这将允许您使用 XPath 选择范围的内容。
然后您可以使用诸如
之类的语法HtmlDocument doc = new HtmlWeb().Load(String.Format("http://sitecontainingspan.com"));
var value = doc.DocumentNode.SelectSingleNode("//span[@class='market_listing_price market_listing_price_with_fee']").InnerText;
这应该加载页面,找到具有正确类的跨度并从中提取值。
