-1

I have the following url source page:

<input type="hidden" name="QQQ" value="AAA" />
<input type="hidden" name="WWW" value="BBB" />
<input type="hidden" name="EEE" value="CCC" />
<input type="hidden" name="WANTED" value="DDD" />   

I want to extract WANTED where the value is DDD from that. What I tried is:

token=tree.xpath('//input[@type="hidden"]/input[@value="DDD"]/@name')

but it gives me QQQ

MLSC
  • 5,872
  • 8
  • 55
  • 89

2 Answers2

1

try :

token=tree.xpath('//input[@type="hidden" and @value="DDD"]/@name')
flafoux
  • 2,080
  • 1
  • 12
  • 13
0

try the xpath:

//input[@type='hidden'][@value='DDD']/@name
Joel M. Lamsen
  • 7,143
  • 1
  • 12
  • 14