嘿,我有以下HTML:
<DIV class=channel_row><SPAN class=channel>
<DIV class=logo><IMG src='/images/channel_logos/WRCB.png'></DIV>
<P><STRONG>3</STRONG><BR>WRCB </P></SPAN><SPAN style='PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; WIDTH: 0px; PADDING-RIGHT: 0px; HEIGHT: 42px; PADDING-TOP: 0px' class=time>
<DIV style='MARGIN: 10px'><A class=thickbox title='Inside Edition' href='/tv/info/?program_id=20474&height=260&width=612' jQuery171012058627296475072='8'>Inside Edition</A>
<P class=schedule_flags><STRONG class=new_flag>New</STRONG>, <STRONG class=cc_flag>CC</STRONG>, <STRONG class=stereo_flag>Stereo</STRONG></P></DIV></SPAN><SPAN style='PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; WIDTH: 490px; PADDING-RIGHT: 0px; HEIGHT: 42px; PADDING-TOP: 0px' class=time>
<DIV style='MARGIN: 10px'><A class=thickbox title='The Voice' href='/tv/info/?program_id=20475&height=260&width=612' jQuery171012058627296475072='9'>The Voice</A>
<P class=schedule_flags><STRONG class=live_flag>Live</STRONG>, <STRONG class=new_flag>New</STRONG>, <STRONG class=cc_flag>CC</STRONG>, <STRONG class=stereo_flag>Stereo</STRONG></P></DIV></SPAN></DIV>
我现在可以使用以下代码获得一些项目(/ images / channel_logos / WRCB.png,3,WRCB,Inside Edition):
Dim all = New Dictionary(Of String, Object)()
For Each channel In doc.DocumentNode.SelectNodes(".//div[@class='channel_row']")
Dim info = New Dictionary(Of String, Object)()
With channel
info!Logo = .SelectSingleNode(".//img").Attributes("src").Value
info!Channel = .SelectSingleNode(".//span[@class='channel']").ChildNodes(3).ChildNodes(0).InnerText
info!Station = .SelectSingleNode(".//span[@class='channel']").ChildNodes(3).ChildNodes(2).InnerText
Dim style As String = .SelectSingleNode(".//span").Attributes("style").Value
info!Shows = From tag In .SelectNodes(".//a[@class='thickbox']")
Select New With {.Show = tag.Attributes("title").Value}
End With
all.Add(info!Station, info.Item("Shows"))
theLogoURL(theCount) = "http://epbfi.com" & Trim(info.Item("Logo"))
theChannelNum(theCount) = Trim(info.Item("Channel"))
theStationCallLetters(theCount) = Trim(info.Item("Station"))
Dim Shows As String = ""
Dim ShowsDetail As String = ""
Dim tmpShows = all.Item(info!Station)
然而,我无法找到在&lt;之后获得宽度的技巧BR&gt; WRCB&lt; / P&GT;&LT; / SPAN&GT;&LT; SPAN style ='PADDING-BOTTOM:0px; PADDING-LEFT:0px;宽度:0px;
我希望只获得 WIDTH:0px; 。
我可以在上面的代码中修改什么才能获得该值?
答案 0 :(得分:1)
我想你可以试试这个:
.SelectSingleNode(".//span[2]").Attributes("style").Value