string str = File.ReadAllText(@"E:\1.txt");
Regex reg = new Regex(@"(?is)<img[^>]*?src=""([^""]+)""[^>]*?>|(?<=<(?!font\b)[^>]*?>)(?!(?:\s*|(?: )*)<)([^<>]+?)(?=</?[^>]+?>)");
foreach (Match m in reg.Matches(str))
{
if (m.Groups[1].Success)
Console.WriteLine(m.Groups[1].Value);
else
Console.WriteLine(m.Groups[2].Value);
}
在麻烦你帮我加个从页面上面获取<span class="prodList_gridViewCell"></span> 标签内的这些参数,页面有多个这样的span
解决方案 »
- SQL查询问题!
- JavaScript问题,SetCookie和ReadCookie问题(在线等)
- 问一个很傻的问题
- vs2005 运行网站出错
- 阅读器关闭时 read data 的尝试无效。
- 如何实现系统退出??? 急!!!!!!!
- 服务器端的LABEL控件无法显示字符串"Hello"<[email protected]>!怎么办?
- 编译器错误信息: CS0122: 不可访问“anotherfenye.fenye.MyDataGrid_Page(object, System.Web.UI.WebControls.DataGridPageChangedEventA
- ListBox中的Item的值超宽,怎么让其自动出水平滚动条?
- 紧急求助:“OracleInternal.Network.AddressResolution”的类型初始值设定项引发异常
- 实现sql语句
- doc转swf,用到Print2Flash3.dll,但是出现组件错误。
Regex span = new Regex(@"(?is)(?<=<span[^>]*?class=""prodList_gridViewCell""[^>]*?>).*(?=</span>)");
Regex reg = new Regex(@"(?is)<img[^>]*?src=""([^""]+)""[^>]*?>|(?<=<(?!font\b)[^>]*?>)(?!(?:\s*|(?: )*)<)([^<>]+?)(?=</?[^>]+?>)");
foreach (Match mSpan in span.Matches(str))
{
foreach (Match m in reg.Matches(mSpan.Value))
{
if (m.Groups[1].Success)
Console.WriteLine(m.Groups[1].Value);
else
Console.WriteLine(m.Groups[2].Value);
}
}
第一部分取出来的不对,不是<span class="prodList_gridViewCell">的标签也出来了
http://www.skinstore.com/borghese.aspx?avs=Brand%7cBorghese&fa=25我只能给你连接喽,内容太多
用了平衡组取嵌套的,然后在获取你要的数据,你看下结果是不是你要的 string str = File.ReadAllText(@"E:\1.txt");
Regex span = new Regex(@"(?is)<span\s*class=""prodList_gridViewCell"">(?:(?!</?span).)*(?:(?:(?<Open><span[^>]*?>)(?:(?!</?span).)*)*(?:(?<-Open></span>)(?:(?!</?span).)*)*)*(?!(Open))</span>");
Regex reg = new Regex(@"(?is)<img[^>]*?src=""([^""]+)""[^>]*?>|(?<=<(?!font\b)[^>]*?>)(?!(?:\s*|(?: )*)<)([^<>]+?)(?=</?[^>]+?>)");
foreach (Match mSpan in span.Matches(str))
{
foreach (Match m in reg.Matches(mSpan.Value))
{
if (m.Groups[1].Success)
Console.WriteLine(m.Groups[1].Value);
else
Console.WriteLine(m.Groups[2].Value);
}
}
/*
//skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD040-condition
er-treatment.jpg
Borghese Ristorativo Di Vita Conditioner Treatment for Hair and Scalp
This lightweight botanically enriched infusion conditions the hair and scalp.
$18.50
8.4oz
OD040
/resources/nav/nav_add_cart.gif
In Stock
//skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD039-shampoo-t
reatment.jpg
Borghese Shampoo Purificante Cleansing Treatment for Hair and Scalp
A body building formula for greater volume, substance and thickness.
$18.50
8.4oz
OD039
/resources/nav/nav_add_cart.gif
In Stock
//skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD036-piedi-vit
ale.jpg
Borghese Piedi Vitale Therapeutic Foot Creme
Relieve tired, achy feet with this invigorating, lightweight creme.
$21.50
3.5oz
OD036
/resources/nav/nav_add_cart.gif
In Stock
//skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD045-fango-fir
ma-tube.jpg
Borghese Fango Ferma Mud Mask for Face and Body
Skin will feel comfortably hydrated, firmer and invigorated.
/resources/assets/badge_new.jpg
$37.00
7oz
OD045
/resources/nav/nav_add_cart.gif
In Stock
//skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD024-firming-s
erum.jpg
Borghese Siero Intensivo Intensive Firming Serum
This lightweight serum provides moisture to the skin as it tightens and tones in
stantly.
$87.50
1.5oz
OD024
/resources/nav/nav_add_cart.gif
In Stock
//skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD009-body-cont
our-scrub.jpg
Borghese Forma Bella Body Contour Scrub
This cream scrub helps to speed up the cell turnover rate and diminish cellulite
.
$45.00
7oz
OD009
/resources/nav/nav_add_cart.gif
In Stock
//skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD002-sponetta-
face-body-ba.jpg
Borghese Crema Saponetta Face and Body Bar
Ideal for use on both the face and body, this bar leaves skin soft, moisturized
and comfortable.
$18.50
11.46oz
OD002
/resources/nav/nav_add_cart.gif
In Stock
//skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD011-equalizin
g-restorativ.jpg
Borghese Equilibrio Equalizing Restorative
A lightweight, oil free moisturizer that helps to normalize skin.
$45.00
1.7oz
OD011
/resources/nav/nav_add_cart.gif
In Stock
//skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD027-wrinkle-r
elax.jpg
Borghese Insta-Firm Platinum Advanced Wrinkle Relax
This serum reduces wrinkles, smoothes away fine lines, and helps improve skin re
siliency.
$80.00
1oz
OD027
/resources/nav/nav_add_cart.gif
In Stock
//skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD033-tono-body
-lotion.jpg
Borghese Tono Body Lotion
Forms an invisible veil of moisture revealing healthy skin.
$37.50
8.4oz
OD033
/resources/nav/nav_add_cart.gif
In Stock
//skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD008-brillante
-brightening.jpg
Borghese CuraForte Brillante Brightening Moisture Intensifier
This oil-free lotion helps diminish the appearance of dark spots.
$71.00
1.35oz
OD008
/resources/nav/nav_add_cart.gif
In Stock
//skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD031-Vitamin-C
-eye.jpg
Borghese Cura-C Vitamin C Eye Treatment
With daily use, dark circles, fines lines and signs of fatigue seem to disappear
.
$46.00
0.5oz
OD031
/resources/nav/nav_add_cart.gif
Out of Stock*/