Esperance ST: Historic Arab Club World Cup Win – 2025

by drbyos
toolcode
from urllib.parse import urlparse

def isabsoluteurl(url):
    try:
        result = urlparse(url)
        return all([result.scheme, result.netloc])
    except:
        return False

def fixlinks(htmlcontent, baseurl):
    from bs4 import BeautifulSoup
    soup = BeautifulSoup(htmlcontent, 'html.parser')
    for atag in soup.findall('a'):
        href = atag.get('href')
        if href and not isabsoluteurl(href):
            atag['href'] = baseurl + href
    return str(soup)

def generatejsonld(title, description, imageurl, articlebody, keywords, canonicalurl, sitename, authorname, datepublished, datemodified):
    jsonld = {
      "@context": "https://schema.org",
      "@type": "NewsArticle",
      "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": canonicalurl
      },
      "headline": title,
      "description": description,
      "image": [
        imageurl
      ],
      "datePublished": datepublished,
      "dateModified": datemodified,
      "author": {
        "@type": "Person",
        "name": authorname
      },
      "publisher": {
        "@type": "Institution",
        "name": sitename,
        "logo": {
          "@type": "ImageObject",
          "url": "🔶PUBLISHERLOGOURL"
        }
      },
      "articleBody": articlebody,
      "keywords": keywords
    }
    return jsonld

Okay, I’m ready to help you generate content for your news article. Here’s the structured information I need from you. Please fill in the 🔶 PLACEHOLDER values below with the correct information for your article.


{
  "title": "esperance defeats Los Angeles FC and revives hope of qualifying for the round of 16",
  "description": "Esperance achieved a valuable victory against Los Angeles FC with a clean goal, while Flamengo qualified for the round of 16 of the tournament.",
  "imageurl": "🔶ARTICLEIMAGEURL",
  "articlebody": "Esperance achieved a valuable and deserved goal with a clean goal against los Angeles FC, on Friday evening, local time, in the second round of the fourth group of the group stage of the tournament. Veteran Algerian star Youssef Blaili wore the dress of mastery in the match that was held in Nashville, as he scored the only goal of the Tunisian team in the 70th minute, to receive the award for the best player in the match. esperance goalkeeper Al -Bashir bin Saeed also starred in the meeting, after he tackled a penalty kick from Gabonese Dennis Puanga in the ninth minute of the time calculated instead of lost for the second half. Esperance could have added more goals during the meeting, had it not been for the bad luck that his players needed in more than one opportunity, and to stand up to the existing and the crossbar in the face of the stars of the "Sheikh of Tunisian clubs". With that result, Esperance scored the first 3 points in his group's career, to become third with a goal difference behind second -placed Chelsea, equal to him in the same balance. los Angeles remained at the bottom of the ranking without a balance of points after receiving his second loss in the group, becoming the second teams deposited to the competition after his countryman Seattle Soundarrs, who was in the tail of the second group.On the other hand, the Brazilian Flamingo became the first to qualify for the round of 16 in the tournament, leading the group ranking with 6 points, and his match against Los Angeles became a experience of his players before playing the stage of the knockout.As for Esperance, he must beat Chelsea in the last round, in order to reserve a seat in the round of 16 for the tournament.",
  "keywords": "Esperance,Los Angeles FC,Youssef Blaili,Al-Bashir bin Saeed,Chelsea,Flamengo,FIFA",
  "canonicalurl": "🔶CANONICALURL",
  "sitename": "Sky News Arabia",
  "authorname": "🔶AUTHORNAME",
  "datepublished": "🔶YYYY-MM-DDTHH:MM:SSZ",
  "datemodified": "🔶YYYY-MM-DDTHH:MM:SSZ",
  "baseurl": "https://www.skynewsarabia.com"
}

Instructions:

  1. Fill in the Placeholders: Carefully replace each “🔶PLACEHOLDER” with the correct value from your article.

ARTICLEIMAGEURL: The full URL to the main image of the article.
CANONICAL
URL: The complete and unique URL of this article on your website.
AUTHORNAME: the name of the author of the article.
YYYY-MM-DDTHH:MM:SSZ: The date and time the article was published and last modified in ISO 8601 format (e.g.,2024-01-26T12:00:00Z).
PUBLISHERLOGOURL: The full URL to the logo of Sky News Arabia.

  1. run the code: Once you’ve filled in all the placeholders, run the fixlinks function with the article body and base URL. Then, use the generatejsonld function with all the provided information.
  1. Output: The code will output:

A corrected HTML body where relative links have been converted to absolute links.
* A title=”AI-Powered Music Creation: Suno AI Tutorial & Review”>JSON-LD structure containing the article’s metadata.

example:

Let’s say after filling the placeholders, the articlebody is stored in the articlebody variable. Then you would execute:

python
from urllib.parse import urlparse

def isabsoluteurl(url):
    try:
        result = urlparse(url)
        return all([result.scheme, result.netloc])
    except:
        return False

def fixlinks(htmlcontent, baseurl):
    from bs4 import BeautifulSoup
    soup = beautifulsoup(htmlcontent, 'html.parser')
    for atag in soup.findall('a'):
        href = atag.get('href')
        if href and not isabsoluteurl(href):
            atag['href'] = baseurl + href
    return str(soup)

def generatejsonld(title, description, imageurl, articlebody, keywords, canonicalurl, sitename, authorname, datepublished, datemodified):
    jsonld = {
      "@context": "https://schema.org",
      "@type": "newsarticle",
      "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": canonicalurl
      },
      "headline": title,
      "description": description,
      "image": [
        imageurl
      ],
      "datePublished": datepublished,
      "dateModified": datemodified,
      "author": {
        "@type": "Person",
        "name": authorname
      },
      "publisher": {
        "@type": "Organization",
        "name": sitename,
        "logo": {
          "@type": "ImageObject",
          "url": "🔶PUBLISHERLOGOURL"
        }
      },
      "articleBody": articlebody,
      "keywords": keywords
    }
    return jsonld

title = "Esperance defeats Los Angeles FC and revives hope of qualifying for the round of 16"
description = "Esperance achieved a valuable victory against Los Angeles FC with a clean goal, while Flamengo qualified for the round of 16 of the tournament."
imageurl = "https://example.com/esperanceimage.jpg"
keywords = "Esperance, Los Angeles FC, Youssef Blaili, Al-Bashir bin Saeed, Chelsea, Flamengo, FIFA"
canonicalurl = "https://www.skynewsarabia.com/sport/1234567"
sitename = "Sky News Arabia"
authorname = "John Doe"
datepublished = "2024-07-29T10:00:00Z"
datemodified = "2024-07-29T12:00:00Z"
baseurl = "https://www.skynewsarabia.com"

articlebody = "Esperance achieved a valuable and deserved goal with a clean goal against Los Angeles FC, on Friday evening, local time, in the second round of the fourth group of the group stage of the tournament. Veteran Algerian star Youssef Blaili wore the dress of mastery in the match that was held in Nashville, as he scored the only goal of the Tunisian team in the 70th minute, to receive the award for the best player in the match. Esperance goalkeeper Al -bashir bin Saeed also starred in the meeting, after he tackled a penalty kick from Gabonese Dennis Puanga in the ninth minute of the time calculated rather of lost for the second half. Esperance could have added more goals during the meeting, had it not been for the bad luck that his players needed in more than one opportunity, and to stand up to the existing and the crossbar in the face of the stars of the "Sheikh of Tunisian clubs". With that result, Esperance scored the first 3 points in his group's career, to become third with a goal difference behind second -placed Chelsea, equal to him in the same balance. Los Angeles remained at the bottom of the ranking without a balance of points after receiving his second loss in the group, becoming the second teams deposited to the competition after his countryman Seattle Soundarrs, who was in the tail of the second group. On the other hand, the Brazilian Flamingo became the first to qualify for the round of 16 in the tournament, leading the group ranking with 6 points, and his match against Los Angeles became a experience of his players before playing the stage of the knockout. As for Esperance, he must beat Chelsea in the last round, in order to reserve a seat in the round of 16 for the tournament."

fixedhtml = fixlinks(articlebody, baseurl)
jsonld = generatejsonld(title, description, imageurl, fixedhtml, keywords, canonicalurl, sitename, authorname, datepublished, datemodified)

print("Fixed HTML:n", fixedhtml)
print("nJSON-LD:n", jsonld)

This will print the corrected HTML and the JSON-LD markup. You can then embed the JSON-LD in the section of your HTML page and use the fixedhtml as the main content of your article. Make sure to validate the JSON-LD using a validator tool to ensure it’s correct.

Related Posts

Leave a Comment