casperjs 中的 fetchText 不返回嵌入 link
fetchText in casperjs not returning embed link
Casperjs 是在各种站点上测试某些功能的好方法。
我使用的示例站点是教程的一部分。
以下站点提供了我无法 console.log 使用的嵌入代码
fetchText,使用 casperjs。嵌入代码可以在你的个人博客中插入link指向特定内容;在本例中是一张音乐专辑:
https://linkmaker.itunes.apple.com/en-us/details/1053933969
要抓取的元素如下:
<a href="https://geo.itunes.apple.com/us/album/a-head-full-of-dreams/id1053933969?mt=1&app=music" target="_blank">https://geo.itunes.apple.com/us/album/a-head-full-of-dreams/id1053933969?mt=1&app=music</a>
检查员截图如下
大部分标记的两个快照
请看下面我一直在使用的代码:
var theTextIWant=casper.fetchText(x('//*[@id="695806055"]/div[4]/div[2]'));
console.log(theTextIWant);
没有返回任何错误,脚本与页面上的其他 link 或文本完美配合。例如以下内容:
var theTextIWant=casper.fetchText(x('//*[@id="1053933969"]/div[4]/div[2]/a'));
console.log(theTextIWant);
在浏览了相关的 casperjs 文档后,我找不到
替代嵌入代码上的 fetchText。我错过了什么吗
允许我 console.log 嵌入代码的 casperjs 文档?
一如既往,非常感谢您的帮助!
如果您需要更多信息,请告诉我。
您似乎想要检索文本区域的值。 casper.fetchText()
仅连接所选上下文元素的所有后代元素的 TextNode,但 <textarea>
没有子 TextNode,就像 <input>
没有它们一样。您必须访问只能在 page context:
中访问的文本区域的 value
属性
casper.then(function(){
this.echo(this.evaluate(function(){
return document.getElementById("link-code").value;
}));
});
Casperjs 是在各种站点上测试某些功能的好方法。
我使用的示例站点是教程的一部分。
以下站点提供了我无法 console.log 使用的嵌入代码 fetchText,使用 casperjs。嵌入代码可以在你的个人博客中插入link指向特定内容;在本例中是一张音乐专辑:
https://linkmaker.itunes.apple.com/en-us/details/1053933969
要抓取的元素如下:
<a href="https://geo.itunes.apple.com/us/album/a-head-full-of-dreams/id1053933969?mt=1&app=music" target="_blank">https://geo.itunes.apple.com/us/album/a-head-full-of-dreams/id1053933969?mt=1&app=music</a>
检查员截图如下
大部分标记的两个快照
请看下面我一直在使用的代码:
var theTextIWant=casper.fetchText(x('//*[@id="695806055"]/div[4]/div[2]'));
console.log(theTextIWant);
没有返回任何错误,脚本与页面上的其他 link 或文本完美配合。例如以下内容:
var theTextIWant=casper.fetchText(x('//*[@id="1053933969"]/div[4]/div[2]/a'));
console.log(theTextIWant);
在浏览了相关的 casperjs 文档后,我找不到 替代嵌入代码上的 fetchText。我错过了什么吗 允许我 console.log 嵌入代码的 casperjs 文档?
一如既往,非常感谢您的帮助!
如果您需要更多信息,请告诉我。
您似乎想要检索文本区域的值。 casper.fetchText()
仅连接所选上下文元素的所有后代元素的 TextNode,但 <textarea>
没有子 TextNode,就像 <input>
没有它们一样。您必须访问只能在 page context:
value
属性
casper.then(function(){
this.echo(this.evaluate(function(){
return document.getElementById("link-code").value;
}));
});