Answer the question
In order to leave comments, you need to log in
Can't parse user with jQuery. What's wrong?
The code:
var url = "http://steamcommunity.com/groups/fnatic#members";
request(url, function (error, response, body) {
if (!error) {
var $ = cheerio.load(body);
var user = $(".member_block_content div a.linkFriend").attr("href").html();
console.log(user);
} else {
console.log("Произошла ошибка: " + error);
}
});
TypeError: Cannot read property 'html' of undefined
at Request._callback (C:\Users\user\Desktop\socket server\server.js:20:76)
at Request.self.callback (C:\Users\user\Desktop\socket server\node_modules\request\request.js:200:22)
at emitTwo (events.js:87:13)
at Request.emit (events.js:172:7)
at Request.<anonymous> (C:\Users\user\Desktop\socket server\node_modules\request\request.js:1067:10)
at emitOne (events.js:82:20)
at Request.emit (events.js:169:7)
at IncomingMessage.<anonymous> (C:\Users\user\Desktop\socket server\node_modules\request\request.js:988:12)
at emitNone (events.js:72:20)
at IncomingMessage.emit (events.js:166:7)
Answer the question
In order to leave comments, you need to log in
var user = $(".member_block_content div a.linkFriend").attr("href").html();
var users = [];
$("a.linkFriend").each(function(i, user) {
users[i] = $(this).attr("href");
console.log(users[i]);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question