Retrieve page title from URL in Apps Script

2019-07-29 04:00发布

问题:

i need to retrieve the page title from an URL i already have using Apps Script.

  var url= r.getValue();
  var title= magically_retrieve_title(url);
  setTitle(title)

How can i do that?

回答1:

If you want to get the title of the page at a 'normal' URL, then you can get the contents of the page using UrlFetchApp.fetch(url) and then parse the title tag.

If not, then please provide more information- what is r here ? What sort of URL are you working with ?