Manually changing xpath for import.io with dt tag

Writing xpath overrides is still a struggle for me after going through training blogs and W3schools. I am trying to extract attribute values ​​from a site where the information is not always in the same place, so I know that I need to write an xpath override. HTML:

<dt>3TG:</dt> 
<dd>Does not contain 3TG</dd>
<dt>Contract Catalog Item:</dt>
<dd>Y</dd> 
<dt>Diameter:</dt>
<dd>3/8"</dd>
<dt>Diameter-Thread Size:</dt>
<dd>3/8"-16</dd>
<dt>Finish:</dt>
<dd>Zinc</dd>
<dt>Grade:</dt>
<dd>5</dd>
<dt>Length:</dt>
<dd>1"</dd>
<dt>Material:</dt>
<dd>Steel</dd>

xpath -

//*[@id="main"]/div[1]/div[4]/div/div[1]/div[1]/dl/dt[4]

I tried

//*[@id="main"]/div[1]/div[4]/div/div[1]/div[1]/dl/dt[contains(text(), "Finish")]/following-sibling::dt/text()

and

//*[@id="main"]/div[1]/div[4]/div/div[1]/div[1]/dl/td/dd[.="Finish:"]/following::dd

But no luck. I'm not sure if he will follow or the next brother. Any help would be greatly appreciated.

+4
source share
1 answer
//*[text()="XXXX"]/following-sibling::*

Change XXXX to what you want

EG: If you want to know information about "3TG:", it will look like this.

//*[text()="3TG:"]/following-sibling::*

<dt>3TG:</dt> 
<dd>Does not contain 3TG</dd>

, xPath TEXT "3TG:", , ( ).

, :

//dt[text()="3TG:"]/following-sibling::dd

<dt>3TG:</dt> 
<dd>Does not contain 3TG</dd>
0

All Articles