-1

I have the following HTML:

<label id="w-57265">
<div class="radio same-option-inline" id="inline-condition-108103" style="border-color: rgb(204, 204, 204); border-width: 1px; border-style: solid;">
    <span class="">
        <input type="radio" name="option[57265]" value="108103">
        26EU <span class="specialPricevar" data-price="44.10 AED"></span>
        <span class="realPricevar" data-price="77.70 AED"></span>
        <small style="display: none;">Foot Size 16.5cm</small>
    </span>
    <span id="tickmark" class=""></span>
</div>

I want to get "26EU" via css selector using lxml

i had already tried this

doc.cssselect('label .same-option-inline')

but it returned all of text in the tag

26EU

Foot Size 16.2cm

what is the correct method to get "26EU" and "Foot Size 16.2cm" each one alone ? (without spaces)

1 Answers1

0

You can try being more specific for Foot Size doc.cssselect('label .same-option-inline small') will return "Foot Size 16.5cm"

However, you cannot directly get 26EU as it's not encapsulated in any tag on it's own (It is wrapped in <span class=""> but so is Foot Size. That is why you are getting both these entities together.)

You can try replacing 25EU with <p>25EU</p> and then using doc.cssselect('label .same-option-inline p')

This will return only 25EU.

DumbCoder7
  • 255
  • 1
  • 8