I want to find all the subpages of [[Template:Did you know nominations]] on enwiki. I think I want to use Site.search(), but I can't get my head around the docs. The pywiki doc page points me to https://www.mediawiki.org/wiki/API:Search which implies I need to be constructing a CirusSearch query string, and after that I'm stuck.
You don't need a search to get the subpages - there's a special page[1] providing links to all subpages:
https://en.wikipedia.org/wiki/Special:PrefixIndex/Template:Did_you_know/
HTH florian
[1] https://en.wikipedia.org/wiki/Help:Special_page
Am 18.09.25 um 17:05 schrieb Roy Smith:
I want to find all the subpages of [[Template:Did you know nominations]] on enwiki. I think I want to use Site.search(), but I can't get my head around the docs. The pywiki doc page points me tohttps://www.mediawiki.org/wiki/API:Search which implies I need to be constructing a CirusSearch query string, and after that I'm stuck.
pywikibot mailing list --pywikibot@lists.wikimedia.org Public archives athttps://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email topywikibot-leave@lists.wikimedia.org
But that's a web page. I'm looking for something I can call in a Python script as a function.
On Sep 18, 2025, at 3:32 PM, tohuuu th@tohuuu.de wrote:
You don't need a search to get the subpages - there's a special page[1] providing links to all subpages:
https://en.wikipedia.org/wiki/Special:PrefixIndex/Template:Did_you_know/
HTH florian
[1] https://en.wikipedia.org/wiki/Help:Special_page
Am 18.09.25 um 17:05 schrieb Roy Smith:
I want to find all the subpages of [[Template:Did you know nominations]] on enwiki. I think I want to use Site.search(), but I can't get my head around the docs. The pywiki doc page points me to https://www.mediawiki.org/wiki/API:Search which implies I need to be constructing a CirusSearch query string, and after that I'm stuck.
pywikibot mailing list -- pywikibot@lists.wikimedia.org mailto:pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org mailto:pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
Hmmm, Looking through the source, I see PrefixingPageGenerator https://github.com/wikimedia/pywikibot/blob/15f6d2bad62009d7efe9e2eb339691001f62d116/pywikibot/pagegenerators/_generators.py#L109(), which is sort of what I want, but doesn't seem to support the various options like sorting by creation date, which I need to do, i.e. I only want to get the N most recently created pages.
On Sep 18, 2025, at 4:24 PM, Roy Smith roy@panix.com wrote:
But that's a web page. I'm looking for something I can call in a Python script as a function.
On Sep 18, 2025, at 3:32 PM, tohuuu th@tohuuu.de wrote:
You don't need a search to get the subpages - there's a special page[1] providing links to all subpages:
https://en.wikipedia.org/wiki/Special:PrefixIndex/Template:Did_you_know/
HTH florian
[1] https://en.wikipedia.org/wiki/Help:Special_page
Am 18.09.25 um 17:05 schrieb Roy Smith:
I want to find all the subpages of [[Template:Did you know nominations]] on enwiki. I think I want to use Site.search(), but I can't get my head around the docs. The pywiki doc page points me to https://www.mediawiki.org/wiki/API:Search which implies I need to be constructing a CirusSearch query string, and after that I'm stuck.
pywikibot mailing list -- pywikibot@lists.wikimedia.org mailto:pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org mailto:pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
It should be trivial to build your own generator, something like
def OrderedPrefixingPageGenerator(prefix, site, namespace=None): pages = pagegenerators.PrefixingPageGenerator( prefix=prefix, site=site, namespaces=namespace ) pages_sorted_desc = sorted(pages, key=lambda p: p.latest_revision.timestamp, reverse=True) for p in pages_sorted_desc: yield p
Takes a bunch of memory, but it should be fairly quick.
Hth, Strainu
Pe joi, 18 septembrie 2025, Roy Smith roy@panix.com a scris:
Hmmm, Looking through the source, I see PrefixingPageGenerator https://github.com/wikimedia/pywikibot/blob/15f6d2bad62009d7efe9e2eb339691001f62d116/pywikibot/pagegenerators/_generators.py#L109(), which is sort of what I want, but doesn't seem to support the various options like sorting by creation date, which I need to do, i.e. I only want to get the N most recently created pages.
On Sep 18, 2025, at 4:24 PM, Roy Smith roy@panix.com wrote:
But that's a web page. I'm looking for something I can call in a Python script as a function.
On Sep 18, 2025, at 3:32 PM, tohuuu th@tohuuu.de wrote:
You don't need a search to get the subpages - there's a special page[1] providing links to all subpages:
https://en.wikipedia.org/wiki/Special:PrefixIndex/Template:Did_you_know/
HTH florian
[1] https://en.wikipedia.org/wiki/Help:Special_page
Am 18.09.25 um 17:05 schrieb Roy Smith:
I want to find all the subpages of [[Template:Did you know nominations]] on enwiki. I think I want to use Site.search(), but I can't get my head around the docs. The pywiki doc page points me to https://www.mediawiki.org/wiki/API:Search which implies I need to be constructing a CirusSearch query string, and after that I'm stuck.
pywikibot mailing list -- pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@ lists.wikimedia.org/message/ABOKZVTIL4JGLGAI4V4YUTMQHVLM5Y43/ To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@ lists.wikimedia.org/message/SJVP5CXFJROEEV5L3TO2DR3MJ5KB6MDH/ To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
site.allpages(prefix="Did you know nominations/", namepsace=10, total=10) is the equivalent of PrefixIndex, but it doesn't support ordering by creation.
site.search('intitle:"^Did you know nominations/"', namespaces=10, sort="create_timestamp_desc", total=10) is probably close to what you want.
Regards, JJ
On Thu, Sep 18, 2025 at 1:34 PM Roy Smith roy@panix.com wrote:
Hmmm, Looking through the source, I see PrefixingPageGenerator https://github.com/wikimedia/pywikibot/blob/15f6d2bad62009d7efe9e2eb339691001f62d116/pywikibot/pagegenerators/_generators.py#L109(), which is sort of what I want, but doesn't seem to support the various options like sorting by creation date, which I need to do, i.e. I only want to get the N most recently created pages.
On Sep 18, 2025, at 4:24 PM, Roy Smith roy@panix.com wrote:
But that's a web page. I'm looking for something I can call in a Python script as a function.
On Sep 18, 2025, at 3:32 PM, tohuuu th@tohuuu.de wrote:
You don't need a search to get the subpages - there's a special page[1] providing links to all subpages:
https://en.wikipedia.org/wiki/Special:PrefixIndex/Template:Did_you_know/
HTH florian
[1] https://en.wikipedia.org/wiki/Help:Special_page
Am 18.09.25 um 17:05 schrieb Roy Smith:
I want to find all the subpages of [[Template:Did you know nominations]] on enwiki. I think I want to use Site.search(), but I can't get my head around the docs. The pywiki doc page points me to https://www.mediawiki.org/wiki/API:Search which implies I need to be constructing a CirusSearch query string, and after that I'm stuck.
pywikibot mailing list -- pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
I guess I can do my own sorting. There's 20 years x 365 days x 8-ish per day or about 60k total nomination, so sorting on the client side wouldn't be a disaster.
On Sep 18, 2025, at 5:10 PM, JJMC89 jjmc89.wikimedia@gmail.com wrote:
site.allpages(prefix="Did you know nominations/", namepsace=10, total=10) is the equivalent of PrefixIndex, but it doesn't support ordering by creation.
site.search('intitle:"^Did you know nominations/"', namespaces=10, sort="create_timestamp_desc", total=10) is probably close to what you want.
Regards, JJ
On Thu, Sep 18, 2025 at 1:34 PM Roy Smith <roy@panix.com mailto:roy@panix.com> wrote:
Hmmm, Looking through the source, I see PrefixingPageGenerator https://github.com/wikimedia/pywikibot/blob/15f6d2bad62009d7efe9e2eb339691001f62d116/pywikibot/pagegenerators/_generators.py#L109(), which is sort of what I want, but doesn't seem to support the various options like sorting by creation date, which I need to do, i.e. I only want to get the N most recently created pages.
On Sep 18, 2025, at 4:24 PM, Roy Smith <roy@panix.com mailto:roy@panix.com> wrote:
But that's a web page. I'm looking for something I can call in a Python script as a function.
On Sep 18, 2025, at 3:32 PM, tohuuu <th@tohuuu.de mailto:th@tohuuu.de> wrote:
You don't need a search to get the subpages - there's a special page[1] providing links to all subpages:
https://en.wikipedia.org/wiki/Special:PrefixIndex/Template:Did_you_know/
HTH florian
[1] https://en.wikipedia.org/wiki/Help:Special_page
Am 18.09.25 um 17:05 schrieb Roy Smith:
I want to find all the subpages of [[Template:Did you know nominations]] on enwiki. I think I want to use Site.search(), but I can't get my head around the docs. The pywiki doc page points me to https://www.mediawiki.org/wiki/API:Search which implies I need to be constructing a CirusSearch query string, and after that I'm stuck.
pywikibot mailing list -- pywikibot@lists.wikimedia.org mailto:pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org mailto:pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org mailto:pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org mailto:pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org mailto:pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org mailto:pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org mailto:pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org mailto:pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/me... To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org