Can you provide examples of parsing HTML?

后端 未结 29 2646
走了就别回头了
走了就别回头了 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:21

    Language: Ruby
    Library: Nokogiri

    #!/usr/bin/env ruby
    require 'nokogiri'
    require 'open-uri'
    
    document = Nokogiri::HTML(open("http://google.com"))
    document.css("html head title").first.content
    => "Google"
    document.xpath("//title").first.content
    => "Google"
    

提交回复
热议问题