2011-04-02 104 views
0

我试图用简单的html dom解析html。HTML DOM解析问题

使用这个例子

<h3> 
<span class="time">19:00 
</span> 
<a href="/simpsons">The Simpsons</a> 
</h3> 
<p class="synopsis">Fat Man and Little Boy: When Bart becomes a t-shirt mogul, and the household's main breadwinner, Homer worries that he no longer has a role in the family. 
</p> 
<a class="link" href="/simpsons/watch">Watch Now</a> 



<h3> 
<span class="time">20:00</span> 
24 
</h3> 
<p class="synopsis">Emotions run high as the harrowing day climaxes with resolute President Taylor closing in on a world-changing peace treaty. 
</p> 


<h3> 
<span class="time">21:00</span> 
<a href="/lost">Lost</a> 
</h3> 
<p class="synopsis">Pseudo-Locke tries to destroy the island and all of its inhabitants, while Jack attempts to stop him. 
</p> 
<a class="link" href="/lost/watch">Watch Now</a> 

我怎么能抢

  1. 的时间
  2. 标题
  3. 的简介
  4. 的链接(如果存在的话)

正如您所看到的源条目不一致,有时标题被封装在锚点中,并且可能不总是具有“立即观看”链接。

+0

不在6个问题..如果它是50或什么的有问题。 – dogmatic69 2011-04-02 13:11:11

+0

对不起,应该是之前做过的。我通常只是发表评论。 – jamjam 2011-04-02 13:12:34

+2

@Madmartigan:如果他们回答了问题,那么他们应该接受答案。通过这种方式,信用在给定的地方给出,并从“未答复的问题”列表中删除。如果您查看@ jamjam的问题,他们中的大多数人都有准确的答案。 – 2011-04-02 13:36:22

回答