如何解决通过phantomjs获取URL片段
我需要获取当前URL的URL片段并将片段(哈希)放入php变量。像这样:
//creating array of report struct
var currentReport = [report]()
//currentReport.append(report(question:questions,AnswersChosen:[String](),userCount:0))
//array for what users are selecting
answerChosen.append(sender.title(for: .normal)!)
//print (answerChosen)
//currentReport.AnswersChosen = answerChosen
print(answerChosen)
//counting number of times wrong button is pressed
ActionCount += 1
//currentReport.userCount = ActionCount
print(ActionCount)
currentReport.append(report(question:questions[currentQuestion],AnswersChosen:answerChosen,userCount:ActionCount))
print(currentReport)
当我在$current_url = exec(phantomjs script.js);
文件中使用window.location.href
时,它显示script.js url。
我需要获取php文件的当前URL,而该文件是fragment(hash)。
我该怎么做。请帮忙。
更新: 我需要获取像phantomjs这样执行的当前php文件的URL:examle.com/need_url_of_this_page.php#11111
解决方法
不确定您要问的是什么,但我想这是您的script.js
中的问题:
var webPage = require('webpage');
var page = webPage.create();
page.open('http://phantomjs.org',function (status) {
var url = page.url;
console.log('URL: ' + url);
phantom.exit();
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。