次のようなJavaScriptを使用するページからURLを取得しようとしています
<span onclick="go1()">click here </span>
<script>function go1(){
window.location = "../innerpages/" + myname + ".php";
}
</script>
これは、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"'
それが動作します
ページ内のテキストを処理できるようですが、URLを取得できませんgo1()
内部の URL を取得したい場合はどうすればよいですかgo1()
ありがとう!