<span>使用CSS Selector 的nth-of-type 抓取特定位置資訊

Steven Wang
Jul 22, 2017 · 1 min read

<p>
<span>1</span>
<span>2</span>
<span>3</span>
<span>4</span>
<span>5</span>
<span>6</span>
</p>

取出資訊spam:nth-of-type(2)

print reup.select(‘.cg2.mt12 spam:nth-of-type(2)’)[0].text

print reup.select(‘.cg2.mt12 spam:nth-of-type(4)’)[0].text

print reup.select(‘.cg2.mt12 spam:nth-of-type(6)’)[0].text

Reference From 大數學堂

)
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade