query-8b14ec6c1157e5e8dab122c3256ccbef
1) Find all items for Wikimedia disambiguation pages with a label "FFCC" in any language.
2) Find all Wikimedia pages for the items.
3) Find all outgoing links (titles and items) on the disambiguation pages.
SELECT DISTINCT ?item ?article ?site ?title ?endpoint ?link_item ?link_title WHERE { SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "www.wikidata.org". bd:serviceParam wikibase:api "Generator". bd:serviceParam mwapi:generator "search". bd:serviceParam mwapi:gsrsearch "inlabel:FFCC". bd:serviceParam mwapi:gsrlimit "max". ?item wikibase:apiOutputItem mwapi:title. } ?item rdfs:label ?label. FILTER (STR(?label) = "FFCC") ?item wdt:P31/wdt:P279* wd:Q4167410. ?article schema:about ?item. ?article schema:isPartOf ?site. ?article schema:name ?title. BIND (STRBEFORE(STRAFTER(STR(?site), "https://"), "/") AS ?endpoint) OPTIONAL { SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint ?endpoint. bd:serviceParam wikibase:api "Generator". bd:serviceParam mwapi:generator "links". bd:serviceParam mwapi:titles ?title. bd:serviceParam mwapi:gpllimit "max". bd:serviceParam mwapi:gplnamespace "0". ?link_item wikibase:apiOutputItem mwapi:item. ?link_title wikibase:apiOutput mwapi:title. } } }
Use at
- https://query.wikidata.org/sparql
PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# 1) Find all items for Wikimedia disambiguation pages with a label "FFCC" in any language.
# 2) Find all Wikimedia pages for the items.
# 3) Find all outgoing links (titles and items) on the disambiguation pages.
SELECT DISTINCT ?item ?article ?site ?title ?endpoint ?link_item ?link_title
WHERE
{
SERVICE wikibase:mwapi
{
bd:serviceParam wikibase:endpoint "www.wikidata.org".
bd:serviceParam wikibase:api "Generator".
bd:serviceParam mwapi:generator "search".
bd:serviceParam mwapi:gsrsearch "inlabel:FFCC".
bd:serviceParam mwapi:gsrlimit "max".
?item wikibase:apiOutputItem mwapi:title.
}
?item rdfs:label ?label.
FILTER (STR(?label) = "FFCC")
?item wdt:P31/wdt:P279* wd:Q4167410.
?article schema:about ?item.
?article schema:isPartOf ?site.
?article schema:name ?title.
BIND (STRBEFORE(STRAFTER(STR(?site), "https://"), "/") AS ?endpoint)
OPTIONAL
{
SERVICE wikibase:mwapi
{
bd:serviceParam wikibase:endpoint ?endpoint.
bd:serviceParam wikibase:api "Generator".
bd:serviceParam mwapi:generator "links".
bd:serviceParam mwapi:titles ?title.
bd:serviceParam mwapi:gpllimit "max".
bd:serviceParam mwapi:gplnamespace "0".
?link_item wikibase:apiOutputItem mwapi:item.
?link_title wikibase:apiOutput mwapi:title.
}
}
}