0
、未定義href! Googleの検索結果ページ(DOMのAPI)
document.getElementsByClassName("l")[0]
//"l" is the class for the URL's of the results.
戻り値は不定。
しかし、
alert(document.getElementsByClassName("l")[0]);
は、最初の結果の実際のURLが表示されます。
結果のURLにアクセスするだけです。
//Adding
.href //to the end does not help
あなたは、あなたのブラウザのコンソールに行くと
document.getElementsByClassName("l")[0]
私にとってはうまく動作します。また、APIを使用しないでください。 –
誰がAPIですか?思考文書。*はDOM APIでした –
彼はGoogle検索APIを参照しています。検索結果ページをスクレイプするのに使いやすいはずです –