页面:http://item.taobao.com/item.htm?id=7257454883
提取页面title:
<div class="tb-gallery">下img图片地址:
<strong id="J_StrPrice" >29.99</strong>下价格:29.99
求用正则怎么获取?
提取页面title:
<div class="tb-gallery">下img图片地址:
<strong id="J_StrPrice" >29.99</strong>下价格:29.99
求用正则怎么获取?
ep:
string pstr ="(is)<title>(?<Title>.*?)</title>.*?<strong id=\"J_StrPrice\" >(?<Price>.*?)</strong>";
Match m = Regex.Match(input, pstr);
if(m.Success)
{
string title = m.Groups["Title"].Value;
string price = m.Groups["Price"].Value;
}
document.getElementById("J_StrPrice").innerHTML
(is)<title>(?<Title>.*?)</title>.*?<div class=\"tb-gallery\">.+?<img src = \"<img>(?Img.*?)\"/></div>?<strong id=\"J_StrPrice\" >(?<Price>.*?)</strong>
对吗?没写过!测试不出来!
MatchCollection mc = re.Matches("text");
foreach (Match ma in mc)
{
}
MatchCollection mc = re.Matches("text");
foreach (Match ma in mc)
{
}
这个是价格的~
string title = m.Groups["Title"].Value;
string price = m.Groups["Price"].Value;
string img= m.Groups["Img"].Value;
(?is)<title>(.+?)</title>(?:[^>]*>){239}(\d+(?:\.\d+)?)(?:[^>]*>){143}\s*<a href="([^"]+)分别取1,2,3就是你要的:title,价格,图片地址
http://topic.csdn.net/u/20101008/15/d1a78275-f67f-4a9c-9b87-f9cb92615c32.html