Google Sheet & App Script : how to get image from a link preview? - image

I am trying to reproduce a RSS reader like Feedly with Google Sheet and displaying with Glide as an app on my mobile phone.
Everything's fine with IMPORTFEED() function with titles, description, URL.
But it seems this function doesn't allow pictures to be displayed even if they are in the feed (which is not all the time).
So I am looking for a way to extract the main image from a blog post... the one displayed when you hover on a link in a Google Sheet cell.
I would like to get the link of that image displayed in the link preview and put that link in another cell.
Here is an example:
I tried IMAGE()
and also IMPORTXML when there is an image in the RSS feeds (but not all of them do... so I stopped)
Is it possible in Google Sheet to get the main image from the one displayed in the link preview ?
For instance, one of the blog I want to extract the main picture of a blog article would be Creajv (URL : https://creajv.com/ ; Feed : https://creajv.com/feed/)
So the IMPORTFEED() function I did in Google Sheets was :
=IMPORTFEED("https://creajv.com/feed/";"items";FALSE;3)
Which stands for :
=IMPORFEED(...) the function to import feeds from an URL
"items" the way to pull every data there is in the feed (you can use other parameters and can see all the possibilities on the GoogleFormulas documentation)
FALSE because I don't want the headers to be included
and the number 3 because I want only the last 3 results displayed.
And it displays perfectly : author, description, URL, date
But I did a little digging in Google and found that basically IMPORTFEED() cannot get images from feeds, even if it is added by the author of the blog (he has to add a feature to do it).
So I am now trying to see if there is another way which is not IMPORTFEED() to get every time the main image of a blog post.
And I saw Google Sheet is able to pull instantly it when I copy paste the URL of a blog article within a cell for instance for Creajv :
Print screen of the image I get when I click in the cell which contains the post URL
So my thoughts would be that I can pull the author, date, description etc. with IMPORTFEED (which works perfectly every time) and use a formula on the cell with the URL to get in another cell the URL of the picture pulled from the one in the link preview.
Two other possibilities might also be with Google App Script :
creating with the App Script a custom function
or creating a script pulling the image in a cell every time a new row is added via the IMPORTFEED() function.

Functions only, as Apps Script doesn't run on mobile Apps
How about this solution? I checked the website and inspected the image from the thumbnail.
Luckily, the structure is simple:
<div class="article-image">
<img src="https://creajv.com/wp-content/uploads/2020/11/HighresScreenshot00000.png" alt="Concours de Level Design avec Unreal Engine, du 11/11 au 05/12/2020">
</div>
You can get the url with IMPORTXML, and apply IMAGE to it:
=IMAGE(ImportXml("https://creajv.com/2020/11/08/concours-de-level-design-avec-unreal-engine/", "//div[#class='article-image']//img/#src"))
Since you are already retrieving the post url with your previous formula, change the source url by the correspondent cell:
=IMAGE(ImportXml(C1, "//div[#class='article-image']//img/#src"))
For example:

Related

Extract image link from TinyMCE in Laravel

I'm making an image sitemap for my site I'm trying to extract the image link from the post and I'm using the TinyMCE text editor Need Help pls.
I use this code but the problem is I do this in the controller and I can't do it in the view This code being in the Controller leads to two problems, first, that I will not be able to all the images for one post, but I have to fetch the images of all posts together at once. The second thing or the second problem is that this code extracts the images twice: the link I want and the link inside So I want a solution so that I can extract images for one post
Below is a picture of the code in the controller

Trouble grabbing newest image on web page using IMPORTXML Xpath function

I'm tasked with making some of the images on a website appear in Google Sheets via the -IMPORTXML function. I have a basic knowledge of Xpath, but here I am just trying to show the current image (because it changes often) instead of pulling in the image URL.
On this link: https://www.kissusa.com/nails/best-sellers
I'm using this, returns "N/A": =importxml(A2,"//*[#id='layer-product-list']/div[2]/ol/li1","src")
To get this image in the first row of products: enter image description here
Any suggestions on how this can happen are greatly appreciated.

what is the difference between response.write(image url) and response.binarywrite(image data)?

I am working on a VBscript asp page that is supposed to render a user's photo graph from our database, based on an ID value that is passed to the page via the URL string, to be used in various email functions. This part works great, using the following code to render it:
Response.ContentType = "image/jpg"
Response.BinaryWrite(rsAttPic("ind_photo_ext"))
I was asked to provide a default image, because if the user does not have an image on file in the DB, they get a broken image icon. After some trial and error, I finally got something to work:
if (IsNull(rsAttPic("ind_photo_ext"))) then
Response.Write("<img src='placeholderm.png'/>")
else
Response.ContentType = "image/jpg"
Response.BinaryWrite(rsAttPic("ind_photo_ext"))
end if
This works when testing it through the presentation page on the website (showpic.asp) - both images display as expected, depending on the record being referenced in the URL. However, when that page, showpic.asp, is referenced by other sources (emails sent via campaign software, confirmation emails generated by our CRM software), only the user image shows up as expected. The generic image does not show in the emails, only a broken image link.
What is the difference between the two types of image presentation? I did notice in testing that the user image appears in the browser in the center, black bground all the way around it, while the default image appears in the top left corner of the browser window, white bground. Is that related?

Facebook comment using ajax/django site

I have just one trouble adding fb comments box in my site. I use kust one url and read the content of the site using js. I put in the head the init of my fb app but I have three post in the main page and I want one comment box for every post. To load the comments of my post I use ((myurl)){{post.id}} to make unique the comment box. This url dosen't exist. But show me up difference comment for every. But don't let me moderate.. I mean dont show the moderation tool. But if i change the href of the post to my url real. Show me the noderstion tool but the same comments in every posts. Any idea???
The page is by ajax bwcause is a radio station and need to listwn the station y all contwnt. There is any way to assign thw url "manualy" in thw api of fb?

Google Apps Script to refresh stock chart image from URL

How can I set up a Google Apps Script (or other method) to refresh a stock chart image using the image URL each time the sheet is viewed or on a periodic basis?
For example I have the following image in my Google Sheets file:
http://etf.bannronn.com/stocks/genchart.php?symbol=VOO
...but it is not updating when I load the sheet on following days even though I added the image using the URL(I've compared the charts to be sure).
Any tips on how to do this?
You can append a unique value to the URL so that each time the sheet opens the URL changes though technically it is still the same.
For instance, you can say:
= image("http://etf.bannronn.com/stocks/genchart.php?symbol=VOO" + "#" + rand());

Resources