我有这个HTML页面。我正在尝试提取此div的以下信息:
<div class="clearfix">
<div class="container left">
<div class="logo">
<a href="/teams/belarus/fc-bate-borisov/200/">
<img src="http://cache.images.core.optasports.com/soccer/teams/150x150/200.png" alt="FC BATE Borisov" />
</a>
</div>
</div>
<div class="container middle">
<div class="details clearfix">
<dl>
<dt>Gara</dt>
<dd><a href="/national/belarus/premier-league/2016/regular-season/r34862/">Premier League</a></dd>
<dt>Data</dt>
<dd><a href="/matches/2016/06/25/"><span class='timestamp' data-value='1466877600' data-format='d mmmm yyyy'>25 giugno 2016</span></a></dd>
<dt>Game week</dt>
<dd>14</dd>
<dt>calcio di inizio</dt>
<dd>
<span class='timestamp' data-value='1466877600' data-format='HH:MM'>20:00</span>
(<span class="game-minute">FP'</span>)
</dd>
</dl>
</div>
<div class="details clearfix">
<dl>
<dt>Stadio</dt>
<dd><a href="venue/">Borisov Arena (Barysaw (Borisov))</a></dd>
</dl>
</div>
</div>
<div class="container right">
<div class="logo">
<a href="/teams/belarus/fc-vitebsk/204/">
<img src="http://cache.images.core.optasports.com/soccer/teams/150x150/204.png" alt="FC Vitebsk" />
</a>
</div>
</div>
</div>
</div>
</div>
</div>
特别是标签calcio di inizio - game week - stadio
其实我试过这个正则表达式:<div[^<>]*class="clearfix"[^<>]*>(?<content>.*?)
但是当我在https://regex101.com/上测试时,我无法运行正则表达式。 我认为div的类与多个div相关联,因此这可能是问题所在。
并且没有任何课程可以接受它,任何想法?
答案 0 :(得分:0)
如果你想要获取内容的div添加一个id(例如&#34; myDiv&#34;),你可以运行以下javascript函数来返回它的HTML内容:
document.getElementById("myDiv").innerHTML
我不确定这是否是你想要的,因为它不是正则表达式,但如果是这样,我希望这有帮助!