Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jmeter使用xpath提取器从html响应获取特定类的链接内容_Html_Regex_Xpath_Jmeter - Fatal编程技术网

jmeter使用xpath提取器从html响应获取特定类的链接内容

jmeter使用xpath提取器从html响应获取特定类的链接内容,html,regex,xpath,jmeter,Html,Regex,Xpath,Jmeter,我有一个HTTP响应,其中包含大量“link-product-link”类的链接,例如: <a href="/a4-nw6179-womens-solid-zip-leg-pull-on-pant-sweat-pants/262361511" class="link product-link" data-external-product-id="0000000000000002088900000000000015725311P"></a> 我写 /html/body/a

我有一个HTTP响应,其中包含大量“link-product-link”类的链接,例如:

<a href="/a4-nw6179-womens-solid-zip-leg-pull-on-pant-sweat-pants/262361511" class="link product-link" data-external-product-id="0000000000000002088900000000000015725311P"></a>
我写

/html/body/a[包含(@class,'link-product-link')]

在查询中,但它没有返回我需要的内容。它总是返回默认值

尝试这样做:

string(//a[@class="link product-link"]/@href)
尝试这样做:

string(//a[@class="link product-link"]/@href)

这些链接可能不是
的直接子项。因此,您需要的是:

//a[contains(@class,'link product-link')]
此外,您需要
节点的
href
属性,因此修改查询:

//a[contains(@class,'link product-link')]/@href

这些链接可能不是
的直接子项。因此,您需要的是:

//a[contains(@class,'link product-link')]
此外,您需要
节点的
href
属性,因此修改查询:

//a[contains(@class,'link product-link')]/@href

由于Jmeter中的SAXParseException,您将获得默认值

您必须选择“使用整洁”选项,如下所示

使用下面的XPATH查询

//a[@class="link product-link"]/@href

由于Jmeter中的SAXParseException,您将获得默认值

您必须选择“使用整洁”选项,如下所示

使用下面的XPATH查询

//a[@class="link product-link"]/@href

谢谢,尝试过了,我仍然得到默认值。也许我做错了什么。还有什么要检查的吗(我是jmeter新手)?“默认值”是什么?您是否尝试不使用string()?它是我放在“默认值”字段中xpath查询字段下的字符串。我现在删除了它,我仍然没有得到链接。我试过不用字符串()。我在引用名称中有“href”,然后在新http请求的路径中使用${href}。在结果树中,我只看到GET,在“/”之后没有路径。也许我在这个过程中遗漏了一些步骤?我的XPath是正确的,不知道你那边出了什么问题谢谢,试过了,我仍然得到了默认值。也许我做错了什么。还有什么要检查的吗(我是jmeter新手)?“默认值”是什么?您是否尝试不使用string()?它是我放在“默认值”字段中xpath查询字段下的字符串。我现在删除了它,我仍然没有得到链接。我试过不用字符串()。我在引用名称中有“href”,然后在新http请求的路径中使用${href}。在结果树中,我只看到GET,在“/”之后没有路径。也许我错过了这个过程中的某个步骤?我的XPath是正确的,不知道你那边出了什么问题为什么使用contains()where=就足以进行完全匹配?@sputnick,因为
=
是完全匹配的(正如预期的那样),而CSS选择器允许空格的变化。例如,
class=“foo-bar”
仍然引用class
.foo.bar
,尽管
'foo-bar'='foor-bar'
为false。这是一种使它更加健壮的方法。请记住,我们谈论的是HTML,而不是XML。为什么使用contains()where=就足以进行完全匹配?@sputnick因为
=
是完全匹配的(正如预期的那样),而CSS选择器允许空格的变化。例如,
class=“foo-bar”
仍然引用class
.foo.bar
,尽管
'foo-bar'='foor-bar'
为false。这是一种使它更加健壮的方法。请记住,我们谈论的是HTML,而不是XML。