我正在尝试从使用 javascript 之类的页面中获取 url
<span onclick="go1()">click here </span>
<script>function go1(){
window.location = "../innerpages/" + myname + ".php";
}
</script>
这是我使用带有splash的scrapyjs的代码
def start_requests(self):
for url in self.start_urls:
yield Request(url, self.parse, meta={
'splash': {
'endpoint': 'render.html',
'args': {'wait': 4, 'html': 1, 'png': 1, 'render_all': 1, 'js_source': 'document.getElementsByTagName("span")[0].click()'},
}
})
如果我写
'js_source': 'document.title="hello world"'
它会起作用的
似乎我可以处理页面内的文本,但我无法从中获取 urlgo1()
如果我想获取里面的 url 我该怎么办go1()
谢谢!