Script help - Set website og:image to thumbnail of a bookmark record

Thanks for reply :slightly_smiling_face:

I modify a script of yours, Favicon as icon for bookmark/web archive? - #6 by chrillek

I tried many regex expressions, but no success. :sweat:

The first one regex in the code get an image from the URL of record, but it isn’t the url in og:image content.

Can you help me?

I’m also trying to code in AppleScript, following the example code in Mac Automation Scripting Guide: Parsing HTML

Script:

function performsmartrule(records) {
	var app = Application("DEVONthink 3");
	app.includeStandardAdditions = true;
	

	records.forEach (r => {
	let thumb = "";
    let found = false;
    const URL = r.url();
    const domain = URL.split('/').slice(0,3).join('/');
	
	const HTML = app.downloadMarkupFrom(URL);
    const embImages = app.getEmbeddedImagesOf(HTML, { baseURL: URL});
	if (embImages.length > 0) {
      for (let img of embImages) {
	  found = RegExp('<meta.*?property="og:image".*?>' && 'content="(.*?)".*?').test(HTML);
	  /*found = RegExp('<meta.*?property="og:image".*?>' && '*content="([^"]+)".*\/>').test(HTML);*/
	  /*found = RegExp('<meta.*?property="og:image".*content="(.*?)"').test(HTML);*/
	  /*found = RegExp('<meta.*property="og:image".*content="(.*)".*\/>').test(HTML);*/
	  /*found = RegExp('<meta.*property="og:image(?::url)*".*content="([^"]+)".*\/>').test(HTML);*/
	  /*found = RegExp('<meta [^>]*property=[\"']og:image[\"'] [^>]*content=[\"']([^'^\"]+?)[\"'][^>]*>').test(HTML);*/
	  if (found) {
          thumb = img;
          break; /* exit the loop here */
        }
      }
      if (found && thumb !== "") {
        r.thumbnail = thumb;
      }
    }
  })
}