就像標題所說的那樣,我有一個元標記,我需要刮掉一些信息。 Link 這是從這個網站我試圖提取作者從屬關係。而這些信息,我可以找到與這行代碼的使用谷歌的開發工具:在我需要在javascript中提取的元標記中提供信息
document.getElementsByName('citation_author_institution')
然後我回到了我認爲是一個元素或節點的數組,看起來像這樣:
[<meta name="citation_author_institution" content="Columbia University, New York">, <meta name="citation_author_institution" content="Columbia University, New York">, <meta name="citation_author_institution" content="Columbia University, New York">]
現在我需要訪問內容並將其保存爲一個數組,以便將其放入我的數據庫中。 我曾嘗試過的東西,如
document.getElementsByName('citation_author_institution').textContent
document.getElementsByName('citation_author_institution').getAttribute('content')
但這並不奏效。任何人有任何想法或提示我如何做到這一點?
http://stackoverflow.com/questions/3289302/can-i-get-a-meta-value-with-jquery-js –
我會用的getElementsByTagName開始,真的。理論上,HTML中可能有更多的元素具有相同的名稱。 –