如何在沒有任何類的時候報廢數據我知道使用ID的類,使用document.getElementsByClassName
的類。如何刮沒有使用javascript的類
<tr id="overview-summary-current">
<th scope="row">
<span class="edit-tools">
<a href="#background-experience" class="edit-section" id="control_gen_5">Edit experience
</a>
</span>
<a href="#background-experience" data-trk="prof-0-ovw-curr_pos">Current</a>
</th>
<td>
<ol>
<li>
<strong>
<a href="/company/10097785?trk=prof-0-ovw-curr_pos" dir="auto">SNT Solutions rajkot</a>
</strong>
</li>
</ol>
</td>
</tr>
我想SNT Solutions rajkot
如何使用JavaScript獲得變量值。
trk=prof-0-ovw-curr_pos
在網頁獨特
使用jQuery/Cheerio它簡單的解決方案很容易:'$(「a [href^='/ company'」])。text()',但在純JavaScript中,這是一個痛苦。你必須選擇所有'a'標籤,然後過濾它們和東西。 –
任何使用純JavaScript的方法@JeremyThille –
好吧,如果你在刮,它意味着你正在運行JavaScript服務器端,所以你使用的是Node(或者我缺少的東西)。所以只需要'npm install cheerio'並享受服務器端的jQuery :)爲什麼要麻煩? –