usp.objects.page

Objects that represent a page found in one of the sitemaps.

class usp.objects.page.SitemapPage

Single sitemap-derived page.

__init__(url: str, priority: Decimal = Decimal('0.5'), last_modified: datetime | None = None, change_frequency: SitemapPageChangeFrequency | None = None, news_story: SitemapNewsStory | None = None, images: List[SitemapImage] | None = None, alternates: List[Tuple[str, str]] | None = None)

Initialize a new sitemap-derived page.

Parameters:
  • url – Page URL.

  • priority – Priority of this URL relative to other URLs on your site.

  • last_modified – Date of last modification of the URL.

  • change_frequency – Change frequency of a sitemap URL.

  • news_story – Google News story attached to the URL.

to_dict()

Convert this page to a dictionary.

property alternates: List[Tuple[str, str]] | None

Get the alternate URLs for the URL.

A tuple of (language code, URL) for each <xhtml:link> element with rel="alternate" attribute.

See Alternate Localised Pages reference

Example:

[('fr', 'https://www.example.com/fr/page'), ('de', 'https://www.example.com/de/page')]
property change_frequency: SitemapPageChangeFrequency | None

Get the change frequency of a sitemap URL.

property images: List[SitemapImage] | None

Get the images attached to the URL.

See Google Image reference

property last_modified: datetime | None

Get the date of last modification of the URL.

property news_story: SitemapNewsStory | None

Get the Google News story attached to the URL.

See Google News reference

property priority: Decimal

Get the priority of this URL relative to other URLs on the site.

property url: str

Get the page URL.

class usp.objects.page.SitemapPageChangeFrequency

Change frequency of a sitemap URL.

classmethod has_value(value: str) bool

Test if enum has specified value.

ALWAYS = 'always'
DAILY = 'daily'
HOURLY = 'hourly'
MONTHLY = 'monthly'
NEVER = 'never'
WEEKLY = 'weekly'
YEARLY = 'yearly'
class usp.objects.page.SitemapNewsStory

Single story derived from Google News XML sitemap.

__init__(title: str, publish_date: datetime, publication_name: str | None = None, publication_language: str | None = None, access: str | None = None, genres: List[str] = None, keywords: List[str] = None, stock_tickers: List[str] = None)

Initialize a new Google News story.

Parameters:
  • title – Story title.

  • publish_date – Story publication date.

  • publication_name – Name of the news publication in which the article appears in.

  • publication_language – Primary language of the news publication in which the article appears in.

  • access – Accessibility of the article.

  • genres – List of properties characterizing the content of the article.

  • keywords – List of keywords describing the topic of the article.

  • stock_tickers – List of up to 5 stock tickers that are the main subject of the article.

to_dict() dict

Convert to a dictionary representation.

Returns:

the news story data as a dictionary

property access: str | None

Get the accessibility of the article.

Returns:

Accessibility of the article.

property genres: List[str]

Get list of genres characterizing the content of the article.

Genres will be one “PressRelease”, “Satire”, “Blog”, “OpEd”, “Opinion”, “UserGenerated”

property keywords: List[str]

Get list of keywords describing the topic of the article.

property publication_language: str | None

Get the primary language of the news publication in which the article appears.

It should be an ISO 639 Language Code (either 2 or 3 letters).

property publication_name: str | None

Get the name of the news publication in which the article appears.

property publish_date: datetime

Get the story publication date.

property stock_tickers: List[str]

Get stock tickers that are the main subject of the article.

Each ticker must be prefixed by the name of its stock exchange, and must match its entry in Google Finance. For example, “NASDAQ:AMAT” (but not “NASD:AMAT”), or “BOM:500325” (but not “BOM:RIL”).

Up to 5 tickers can be provided.

property title: str

Get the story title.

class usp.objects.page.SitemapImage

Single image derived from Google Image XML sitemap.

All properties except loc are now deprecated in the XML specification, see https://developers.google.com/search/blog/2022/05/spring-cleaning-sitemap-extensions

They will continue to be supported here.

__init__(loc: str, caption: str | None = None, geo_location: str | None = None, title: str | None = None, license_: str | None = None)

Initialise a Google Image.

Parameters:
  • loc – the URL of the image

  • caption – the caption of the image, optional

  • geo_location – the geographic location of the image, for example “Limerick, Ireland”, optional

  • title – the title of the image, optional

  • license – a URL to the license of the image, optional

to_dict()

Convert to a dictionary representation.

Returns:

the image data as a dictionary

property caption: str | None

Get the caption of the image.

property geo_location: str | None

Get the geographic location of the image.

property license: str | None

Get a URL to the license of the image.

property loc: str

Get the URL of the image.

property title: str | None

Get the title of the image.