How to get element with tag name '<ht:picture_source>' using JQuery?

Viewed 44

I trying to scrape google trends using this RSS feed link

However I couldn't able to get the element with tag name <ht:picture_source>..</ht:picture_source>.

I tried the below code :

$(".trigger").on("click",function() {
    $.ajax({
         url: "https://trends.google.co.in/trends/trendingsearches/daily/rss?geo=US",
         dataType: 'text',
         success: function(data) {

              let post_count = $(data).find('title').length;

              for(let counter = 1; counter < post_count; counter++) {
                  let image = $(data).find('ht:picture').eq(counter).text();
                  console.log(image);
              }
    
          
         }
    });
});

I get undefined or empty on the console.

Someone already checked this up on GigHub 2 years ago.

Any help is greatly appreciated.

1 Answers

Special characters like : need to be escaped in jQuery selectors.

let image = $('body').find('ht\\:picture_source').eq(0).text();
console.log(image);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ht:picture_source>Text</ht:picture_source>

Related