Access the sources and problems companions of a sitemap result
Source:R/audit.R
sitemap_companions.Rdsources() and problems() return the two companion tables the package
produces alongside its tidy URL rows: the per-source fetch-metadata records
and the non-fatal parse problems table. They dispatch on the object type,
so the same call works on a read_sitemap() result and on a
sitemap_audit() object:
Usage
sources(x, ...)
# Default S3 method
sources(x, ...)
# S3 method for class 'sitemap_audit'
sources(x, ...)
problems(x, ...)
# Default S3 method
problems(x, ...)
# S3 method for class 'sitemap_audit'
problems(x, ...)Arguments
- x
A
read_sitemap()result (a tidy tibble carrying thesources/problemsattributes) or asitemap_audit()object.- ...
Ignored; reserved for future methods.
Value
For sources(), the per-source fetch-metadata records; for
problems(), the non-fatal parse problems table. A sitemap_audit()
object always yields the documented (possibly zero-row) component; a
read_sitemap() result yields its attached companion table.
Details
On a
read_sitemap()result, they read thesources/problemsattributes the entry point attaches to the tidy tibble, so callers need not reach forattr().On a
sitemap_audit()object, they return the first-classsources/problemscomponents, delegating toaudit_sources()/audit_problems()for identical behavior.
The default methods return the requested attribute (or NULL when the object
carries none), so they are safe to call on any object.
See also
audit_sources() and audit_problems() for the sitemap_audit
component accessors.
Examples
xml <- paste0(
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
'<url><loc>https://example.com/</loc></url></urlset>'
)
path <- tempfile(fileext = ".xml")
writeLines(xml, path)
urls <- read_sitemap(path)
sources(urls)
#> requested_url final_url
#> 1 /tmp/RtmpqZ8tPh/file19617061f7de.xml /tmp/RtmpqZ8tPh/file19617061f7de.xml
#> status redirect_chain content_type charset bytes timing error_class
#> 1 NA <NA> <NA> 112 NA <NA>
#> format root namespaces profile_id
#> 1 xml-urlset <NA> <NA>
problems(urls)
#> # A tibble: 0 × 4
#> # ℹ 4 variables: severity <chr>, category <chr>, subject_ref <chr>,
#> # message <chr>
# The same accessors work on a sitemap_audit object.
audit <- sitemap_audit(urls = urls)
sources(audit)
#> requested_url final_url
#> 1 /tmp/RtmpqZ8tPh/file19617061f7de.xml /tmp/RtmpqZ8tPh/file19617061f7de.xml
#> status redirect_chain content_type charset bytes timing error_class
#> 1 NA <NA> <NA> 112 NA <NA>
#> format root namespaces profile_id
#> 1 xml-urlset <NA> <NA>
problems(audit)
#> # A tibble: 0 × 4
#> # ℹ 4 variables: severity <chr>, category <chr>, subject_ref <chr>,
#> # message <chr>