-
-
Save havenwood/beeaa6bbdf8c3312473feba7376267b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
require 'nokogiri' | |
url = 'https://www.cnbc.com/2020/04/25/coronavirus-uk-prime-minister-boris-johnson-will-return-to-work-monday.html' | |
html = Nokogiri::HTML open(url, &:read) | |
xpath_query = '//*[@id="RegularArticle-KeyPoints-4"]/div/div[2]/div/div/ul/li[1]/text()' | |
html.xpath(xpath_query).text | |
#=> "Johnson has been convalescing at Chequers, the prime minister's country estate, since he was discharged from hospital earlier this month. " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment