Can you provide examples of parsing HTML?

后端 未结 29 2264
走了就别回头了
走了就别回头了 2020-11-22 13:49

How do you parse HTML with a variety of languages and parsing libraries?


When answering:

Individual comments will be linked to in answers to questions

29条回答
  •  粉色の甜心
    2020-11-22 14:31

    Language: JavaScript
    Library: jQuery

    $.each($('a[href]'), function(){
        console.debug(this.href);
    });
    

    (using firebug console.debug for output...)

    And loading any html page:

    $.get('http://stackoverflow.com/', function(page){
         $(page).find('a[href]').each(function(){
            console.debug(this.href);
        });
    });
    

    Used another each function for this one, I think it's cleaner when chaining methods.

提交回复
热议问题