'How to enter a specific node in xpath with Python and lxml

Imagine the Following HTML

<div class="group>
    <ul class="smallList">
        <li><strong>Date</strong>
            some Date
       </li>
       <li>
            <strong>Author</strong>
            some Name
       </li>
       <li>
            <strong>Keywords</strong>
            <a href="linka"
            rel="nofollow">keyworda</a>,
            <a href="linkb"
             rel="nofollow">Keywordb</a>,
       </li>
       <li>
            <strong>Print</strong>
            <a class="icon print" rel="nofollow" href="javascript:window.print()">print page</a>
       </li>
    </ul>
</div>
<div class="group>
    <ul class="smallList">
        <li><a href="linkc">Linktext</a></li>
    </ul>
<div>

I am looking for keyworda and keywordb. So only the words within the lsistelement that contains Keywords

I can get all the nodes by using

.//div[@class='group']/ul[@class='smallList']/li/a/node()

but how do I enter just the specific one?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source