Web Module

New in version 0.1.0.

Internet-related automation features that extend PyXA scripting functionality.

Classes:

RSSFeed(url)

An RSS feed reader.

RSSItem(properties)

An item or entry in an RSS feed.

RSSItemContent(properties)

The content of an RSS entry.

RSSItemContentList(properties)

RSSItemList(properties)

class PyXA.Additions.Web.RSSFeed(url: str | XAURL)[source]

Bases: XAObject

An RSS feed reader.

New in version 0.1.0.

Methods:

items()

Retrieves all item and/or entry tags in the RSS feed as RSSItem objects.

refetch()

Resends the GET request for the RSS feed URL and updates this object's data accordingly.

items() RSSItemList[source]

Retrieves all item and/or entry tags in the RSS feed as RSSItem objects.

Returns:

The list of items and/or entries

Return type:

RSSItemList

Example:

>>> import PyXA
>>> reader = PyXA.RSSFeed("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/xml")
>>> print(reader.items())
<<class 'PyXA.extensions.XAWeb.RSSItemList'>['Hold Me Closer - Elton John & Britney Spears', 'Only Ever Wanted - Timcast', "I Ain't Worried - OneRepublic", 'wait in the truck - HARDY & Lainey Wilson', 'Bring Me to Life - Evanescence', 'Running Up That Hill (A Deal with God) - Kate Bush', 'Beer With My Friends - Kenny Chesney & Old Dominion', 'American Pie (Full Length Version) - Don Mclean', 'She Had Me At Heads Carolina - Cole Swindell', 'You Proof - Morgan Wallen']>

New in version 0.1.0.

refetch()[source]

Resends the GET request for the RSS feed URL and updates this object’s data accordingly.

Example:

Get the top 10 songs on iTunes every hour

>>> import PyXA
>>> from time import sleep
>>> reader = PyXA.RSSFeed("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/xml")
>>> while True:
>>>     reader.refetch()
>>>     print(reader.items())
>>>     sleep(3600)

New in version 0.1.0.

class PyXA.Additions.Web.RSSItem(properties)[source]

Bases: XAObject

An item or entry in an RSS feed.

New in version 0.1.0.

Attributes:

author

The author of the entry

category

The category of the entry

comments

The comments of the entry

content

The raw content of the entry

copyright

The copyright text of the entry

description

The description of the entry

enclosure

The media idea enclosed in the entry

link

The hyperlink to the entry

publication_date

The most recent publication date of the entry

source

The third-party source of the entry

text

All text within the entry (not just the description/content text!)

title

The title of the RSS entry

xml

The raw XML of the entry

Methods:

links()

Retrieves the URL referenced by each link tag as a list of XABase.XAURL objects.

property author: str

The author of the entry

property category: str

The category of the entry

property comments: str

The comments of the entry

property content: type

The raw content of the entry

property copyright: str

The copyright text of the entry

property description: str

The description of the entry

property enclosure: str

The media idea enclosed in the entry

The hyperlink to the entry

Retrieves the URL referenced by each link tag as a list of XABase.XAURL objects.

Returns:

The list of link URLs

Return type:

List[XABase.XAURL]

Example:

>>> import PyXA
>>> reader = PyXA.RSSFeed("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/xml")
>>> item = reader.items()[0]
>>> print(item.links())
[<<class 'PyXA.XABase.XAURL'>https://audio-ssl.itunes.apple.com/itunes-assets/AudioPreview122/v4/7a/24/60/7a246091-cef8-1df4-1435-a107ed3c6980/mzaf_8623157179635634843.plus.aac.p.m4a>, <<class 'PyXA.XABase.XAURL'>https://music.apple.com/us/album/hold-me-closer-single/1641082201?uo=2>, <<class 'PyXA.XABase.XAURL'>https://music.apple.com/us/album/hold-me-closer/1641082201?i=1641082205&uo=2>]

New in version 0.1.0.

property publication_date: str | None

The most recent publication date of the entry

property source: str

The third-party source of the entry

property text: str

All text within the entry (not just the description/content text!)

property title: str

The title of the RSS entry

property xml: str

The raw XML of the entry

class PyXA.Additions.Web.RSSItemContent(properties)[source]

Bases: XAObject

The content of an RSS entry.

New in version 0.1.0.

Attributes:

html

The raw html of the content

text

The visible text of the content

Methods:

images()

Retrieves the image referenced by each image element as a list of XABase.XAImage objects.

links()

Retrieves the URL referenced by each anchor element as a list of XABase.XAURL objects.

property html: str

The raw html of the content

images() List[XAImage][source]

Retrieves the image referenced by each image element as a list of XABase.XAImage objects.

Returns:

The list of images

Return type:

List[XABase.XAImage]

Example:

>>> import PyXA
>>> reader = PyXA.RSSFeed("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/xml")
>>> content = reader.items()[0].content
>>> print(content.images())
[<PyXA.XABase.XAImage object at 0x10635ee80>, <PyXA.XABase.XAImage object at 0x10635ebb0>]

New in version 0.1.0.

Retrieves the URL referenced by each anchor element as a list of XABase.XAURL objects.

Returns:

The list of link URLs

Return type:

List[XABase.XAURL]

Example:

>>> import PyXA
>>> reader = PyXA.RSSFeed("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/xml")
>>> content = reader.items()[0].content
>>> print(content.links())
[<<class 'PyXA.XABase.XAURL'>https://music.apple.com/us/album/hold-me-closer/1641082201?i=1641082205&uo=2>, <<class 'PyXA.XABase.XAURL'>https://music.apple.com/us/album/hold-me-closer/1641082201?i=1641082205&uo=2>, <<class 'PyXA.XABase.XAURL'>https://music.apple.com/us/album/hold-me-closer-single/1641082201?uo=2>, <<class 'PyXA.XABase.XAURL'>https://music.apple.com/us/artist/elton-john/54657?uo=2>, <<class 'PyXA.XABase.XAURL'>https://music.apple.com/us/genre/music-pop/id14?uo=2>]

New in version 0.1.0.

property text: str

The visible text of the content

class PyXA.Additions.Web.RSSItemContentList(properties)[source]

Bases: XAList

Methods:

html()

Gets the raw HTML of each item in the list.

images()

Gets the images contained in each item of the list as XABase.XAImage objects.

links()

Gets the links contained in each item of the list as XABase.XAURL objects.

text()

Gets the text of each item in the list.

html() List[str][source]

Gets the raw HTML of each item in the list.

Returns:

The list of HTML strings

Return type:

List[str]

New in version 0.1.0.

images() List[XAImage][source]

Gets the images contained in each item of the list as XABase.XAImage objects.

Returns:

The list of links

Return type:

List[XABase.XAImage]

New in version 0.1.0.

Gets the links contained in each item of the list as XABase.XAURL objects.

Returns:

The list of links

Return type:

List[XABase.XAURL]

New in version 0.1.0.

text() List[str][source]

Gets the text of each item in the list.

Returns:

The list of content texts

Return type:

List[str]

New in version 0.1.0.

class PyXA.Additions.Web.RSSItemList(properties)[source]

Bases: XAList

Methods:

author()

Gets the author of each item in the list.

category()

Gets the category of each item in the list.

comments()

Gets the comments of each item in the list.

content()

Gets the content of each item as RSSItemContent objects.

copyright()

Gets the copyright of each item in the list.

description()

Gets the description of each item as RSSItemContent objects.

enclosure()

Gets the enclosure of each item in the list.

link()

Gets the link of each item in the list.

links()

Gets the links contained in each item of the list as XABase.XAURL objects.

publication_date()

Gets the publication date of each item in the list.

source()

Gets the source of each item in the list.

text()

Gets the text of each item in the list.

title()

Gets the title of each item in the list.

xml()

Gets the raw XML of each item in the list.

author() List[str][source]

Gets the author of each item in the list.

Returns:

The list of RSS item authors

Return type:

List[str]

New in version 0.1.0.

category() List[str][source]

Gets the category of each item in the list.

Returns:

The list of RSS item categories

Return type:

List[str]

New in version 0.1.0.

comments() List[str][source]

Gets the comments of each item in the list.

Returns:

The list of RSS item comments

Return type:

List[str]

New in version 0.1.0.

content() RSSItemContentList[source]

Gets the content of each item as RSSItemContent objects.

Returns:

The list of item contents

Return type:

RSSItemContentList

New in version 0.1.0.

copyright() List[str][source]

Gets the copyright of each item in the list.

Returns:

The list of RSS item copyrights

Return type:

List[str]

New in version 0.1.0.

description() RSSItemContentList[source]

Gets the description of each item as RSSItemContent objects.

Returns:

The list of item descriptions

Return type:

RSSItemContentList

New in version 0.1.0.

enclosure() List[str][source]

Gets the enclosure of each item in the list.

Returns:

The list of RSS item enclosures

Return type:

List[str]

New in version 0.1.0.

Gets the link of each item in the list.

Returns:

The list of RSS item links

Return type:

List[str]

New in version 0.1.0.

Gets the links contained in each item of the list as XABase.XAURL objects.

Returns:

The list of links

Return type:

List[XABase.XAURL]

New in version 0.1.0.

publication_date() List[datetime][source]

Gets the publication date of each item in the list.

Returns:

The list of RSS item publication dates

Return type:

List[datetime]

New in version 0.1.0.

source() List[str][source]

Gets the source of each item in the list.

Returns:

The list of RSS item sources

Return type:

List[str]

New in version 0.1.0.

text() List[str][source]

Gets the text of each item in the list.

Returns:

The list of RSS item texts

Return type:

List[str]

New in version 0.1.0.

title() List[str][source]

Gets the title of each item in the list.

Returns:

The list of RSS item titles

Return type:

List[str]

New in version 0.1.0.

xml() List[str][source]

Gets the raw XML of each item in the list.

Returns:

The list of XML strings

Return type:

List[str]

New in version 0.1.0.