From any URL, I would like to get the text inside the tag in its header. For example, in the screenshot below, the text "javascript - Getting the title of a web page given the URL - Stack Overflow" is what I want to extract.
I have been trying to get the header with httr
, but it does not seem to have the title:
library(httr)
url_head <- HEAD(url = "https://stackoverflow.com/questions/10940241/getting-the-title-of-a-web-page-given-the-url"))
url_head
gives
Response [https://stackoverflow.com/questions/10940241/getting-the-title-of-a-web-page-given-the-url]
Date: 2023-06-22 10:01
Status: 200
Content-Type: text/html; charset=utf-8
<EMPTY BODY>
also tried
headers(url_head)
but nothing there either.