我有一个 html 页面
<table class="Tab_AddTovar7">
<tr>
<th><div class="col_tab_1">Вид металла</div></th>
<th><div class="TR_AddTovar_head7">Диаметр</div></th>
<th class="col_tab_1"><div class="TR_AddTovar_head7">Длина</div></th>
<th class="col_tab_1"><div class="TR_AddTovar_head7">ГОСТ, ОСТ, ТУ</div></th>
<th><div class="TR_AddTovar_head7">Марка</div></th>
<th><div class="TR_AddTovar_head7">Цена</div></th>
<th><div class="TR_AddTovar_head7">Купить</div></th>
</tr>
<tr>
<td><a class="col_tab_1" href="/product/tovar01">Цис</a></td>
<td>
<a class="link_tab7">18,0</a>
</td>
<td class="col_tab_1">
<a class="link_tab7">18,0</a>
</td>
<td class="col_tab_1">
<a class="link_tab7" href="/gost/28/19/99/2276"><strong>ТУ 14-176-122-94</strong></a>
</td>
<td >
需要链接/product/product01
我这样做:
for tovar in bf.cssselect('.Tab_AddTovar7 td a'):
ba = tovar.cssselect('a')[0]
bhref = ba.get('href')
但是结果,那些不需要的链接被解析了,我怎样才能确保只有我的链接被解析?
在标签内获取链接的示例
class="Tab_AddTovar7"
:您可以按所有链接过滤,例如: