T
T
tispoint2016-03-11 05:10:30
XPath
tispoint, 2016-03-11 05:10:30

How to formulate the Xpath expression correctly please?

There is approximately the following html (I removed the extra):

<div class="characteristic">Серия	</div>
<div class="value" >ProLiant 	</div>
<div class="clear"></div>
<div class="characteristic">Тип корпуса	</div>
<div class="value" >Rack 	</div>
<div class="clear"></div>

I write something like this (tried in different ways):
l.add_xpath('line', "//div[text()='%s']/following-sibling::div[@class='value']/ text()" % u"Series ")
doesn't work.
Help me please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya, 2016-03-11
@tispoint

Here is quite a working xpath
The main thing with the encoding is that there are no problems. For example, in the case of php, I had to force the text to be converted to UTF-8 before feeding it into the loadHTML () method;

$html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");

T
tispoint, 2016-03-11
@tispoint

I entered the html incorrectly

<div class="char c1 ">
<div class="characteristic">Для процессоров </div>
<div class="value"> Intel  </div>
<div class="clear"/>
</div>
<div class="char c0 ">
<div class="characteristic">Серия процессора </div>
<div class="value"> Xeon  </div>
<div class="clear"/>
</div>

This is a table. It is quite long.
It is necessary that it searches by the characteristic column and returns the value from the value column

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question