I'm currently just trying to test and find out how to pull information from cnn.com and get the some of the titles of the articles with the class name, "cd__headline-text." However, when I use the $.ajax
function to get the titles of the articles on cnn with that class name I get an error that says response.getElementsByClassName is not a function.
Below is the code that prompts this error to happen:
$(document).ready(function(){
$("button").click(function(){
console.log("hi test");
$.ajax({
url: "https://www.cnn.com",
cache: false,
success: function(response){
filter = response.getElementsByClassName("cd__headline-text");
console.log(filter);
}
});
});
});
My current console.log(response);
output is in this link: