如何在 javascript 中获取 link 中的元素?
How do I get an element inside a link in javascript?
我想制作一个模拟器,告诉您该网站上特定用户名个人资料的最后评论。我想从那个 link 中定位一个特定的 class 或 id(link 是“https://scratch.mit.edu/users/oreyelephant/”),并检测最新评论的简单文本,并将其放入在 div 或段落标记中。对于此声明,我想在控制台中声明关于我的文本。这是我拥有的:
var link = "https://scratch.mit.edu/users/oreyelephant/"
var aboutMe = link.getAttribute("editable read");
console.log(aboutMe);
我有 "editable read" 的 getAttribute 的原因是因为那是我试图获取其文本的 class 的名称。 The place where I'm trying to get the text/innerText of
要获取用户的简介,请不要直接尝试那样做,请使用 scratch api。
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET', 'https://api.scratch.mit.edu/users/oreyelephant', true);
xmlhttp.send();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
var response = JSON.parse(xmlhttp.responseText);
console.log(response["profile"]["bio"])
}
};
我想制作一个模拟器,告诉您该网站上特定用户名个人资料的最后评论。我想从那个 link 中定位一个特定的 class 或 id(link 是“https://scratch.mit.edu/users/oreyelephant/”),并检测最新评论的简单文本,并将其放入在 div 或段落标记中。对于此声明,我想在控制台中声明关于我的文本。这是我拥有的:
var link = "https://scratch.mit.edu/users/oreyelephant/"
var aboutMe = link.getAttribute("editable read");
console.log(aboutMe);
我有 "editable read" 的 getAttribute 的原因是因为那是我试图获取其文本的 class 的名称。 The place where I'm trying to get the text/innerText of
要获取用户的简介,请不要直接尝试那样做,请使用 scratch api。
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET', 'https://api.scratch.mit.edu/users/oreyelephant', true);
xmlhttp.send();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
var response = JSON.parse(xmlhttp.responseText);
console.log(response["profile"]["bio"])
}
};