Real-Time News Data

FREEMIUM
Verified
Par OpenWeb Ninja | Mise à jour 2 months ago | Data
Popularité

9.8 / 10

Latence

920ms

Niveau de service

100%

Health Check

100%

Retour à toutes les discussions

photo_url return null

Rapid account: Clems 77270
clems77270
5 months ago

Hi,

Since the 10/01/24, all the photo_url returned are null.

Rapid account: Letscrape 6 B R Ba 3 Qgu O 5
letscrape-6bRBa3QguO5 Commented 4 months ago

Yes, this is exactly what I meant.

Depending on your specific use case, you can also have an endpoint on your backend that takes a path parameter with the id value after “/api/attachments” in the new URL format, gets the 302 location (old format) like in your code and redirects to it. I think that this way you can simply set the backend URL as the img src’s in the html (a CDN could also be used on top to offload the work from the server and speed things up) and avoid the CORS restrictions.

Rapid account: Clems 77270
clems77270 Commented 4 months ago

Yes so now I need to use my backend server to request the image. Here is my controller, if it can be useful where “imageUrl” is the new format url :

export const fetchImage = async (req, res) => {
const imageUrl = req.query.url;
try {
const response = await axios.get(imageUrl, {
maxRedirects: 0, // Don’t follow redirects
validateStatus: (status) => status === 302, // Expect a 302 redirect status
});
const redirectedUrl = response.headers.location; // Get the URL from the redirect header
console.log(“redirectedUrl”, redirectedUrl);
res.json({ redirectedUrl });
} catch (error) {
res.status(500).send(“Error fetching image”);
}
};

Rapid account: Letscrape 6 B R Ba 3 Qgu O 5
letscrape-6bRBa3QguO5 Commented 4 months ago

Hi there,

Yes, I see that, thanks bringing this up.

There was a change in the photo URL format, as it comes from Google News.
Old format example: https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQ1LI6x4nz4BYI-zzdTcimtFY7WKjHcsEsIZt_v0j9SaUGM8yglYj4o93mzwtj0P1k
New format example: https://news.google.com/api/attachments/CC8iL0NnNWpWVVZJVWxoT04xcG1iR2hvVFJDbUFSaXZBaWdCTWdtSlVwREZKaWhGekFF

It also seems like the URL with the new format, which has CORS disabled, redirects to the old format URL, which has CORS enabled. Given that, in case CORS is a must, the new photo URLs be potentially preprocessed to get the target old format URL before displaying on a web page.

Thank you,
Adam @ OpenWeb Ninja

Rapid account: Clems 77270
clems77270 Commented 4 months ago

Hi Adam,
Thank you for your response and your availability!

I think that Google News have set there url management because the photo_url link is now with a CORS control.

Rapid account: Letscrape 6 B R Ba 3 Qgu O 5
letscrape-6bRBa3QguO5 Commented 5 months ago

Hi,

Thank you for bringing this to my attention. There was indeed a change on Google’s side that requires an adaptation. This should now be fixed.

Thank you and sorry for the inconvenience,
Adam @ OpenWeb Ninja

Participez à la discussion - ajoutez un commentaire ci-dessous:

Connectez-vous / Inscrivez-vous pour publier de nouveaux commentaires