Найти - Пользователи
Полная версия: вопрос по xpath
Начало » Python для новичков » вопрос по xpath
1
gelius
Собираю ссылки залинкованные с картинок вот так:
urls = urls.xpath('//img/parent::a[not(re:match(@href, "(slovo)")) ]/@href', namespaces={"re": "http://exslt.org/regular-expressions"})
Споткнулся на таком html:
<li>
<a href="/url/link.html" title="title"><span class="image"><img src="http://domain.com/1.jpg" alt="alt"></span><span class="title">title</span></a>
</li>
Видимо благодаря “<span class=”image“>”.
Какие варианты сделать наиболее универсально?
Master_Sergius
мб регулярками?
lorien
Попробуйте так:

a[img or span/img]//img[...]
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB