-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to parse href tags #1
Comments
with above code I get output as
Now I just need to get hrefs. |
I hardly can imagine universal solution for my plugin in this case without using eval. Using eval is bad practice I think. Getting attribute from tag not the only possible way to get data from table. In yours case I think this code will works OK. function getHrefsFromArray(arr) {
var result = []
for (var i = 0; i < arr.length; i++) {
var row = arr[i];
result[i] = []
for (var j = 0; j < row.length; j++) {
var href = $('<div>' + row[j] + '</div>').find("a").attr("href")
if (href != undefined) {
result[i][j] = href
} else {
result[i][j] = "" // or some text for undefined result
}
}
}
return result
}
var $ = cheerio.load(html);
cheerioTableparser($);
var data = $(".qualification-grid").parsetable(false, false, false);
//var strong = $('<div>' + data[0][0] + '</div>').find('a').text();
console.log(data[0][0]);
hrefsArray = getHrefsFromArray(data) |
Thanks @misterparser ...I will give it a try and keep you posted |
If yours task do not connected with table structure you can just do something like this. $(".qualification-grid a").each(function(i, r) {
console.log($(r).attr("href"))
}) My plugin is only for solve problem with colspan and rowspan tags. |
I have list tables with below structure and I want to get all href from those tables
Is it possible to accomplish this?
The text was updated successfully, but these errors were encountered: