比如:
<h3 class="capsule">
::before
"
Thiosemicarbazone organocatalysis: tetrahydropyranylation and 2-deoxygalactosylation reactions and kinetics-based mechanistic investigation
"
</h3>
爬虫好像会忽略掉::before。
爬虫爬取h3,然后正则"(<h3[^>]+>)|(<\/h3>)"
,会出现:
Thiosemicarbazone organocatalysis: tetrahydropyranylation and 2-deoxygalactosylation reactions and kinetics-based mechanistic investigation >
莫名其妙多出一个>
不知什么原因?
::before和::after是伪元素。伪元素就是文档中若有实无的元素。伪元素实际上是替我们增加了无形的标签。
可用于在特定元素前面或后面添加特殊内容。以下标记:
应用如下样式:
可以得到:
Age: 25 years
也可以在应用他们的元素外面附着一个动态的新元素,从而得到一个有趣的布局效果。