extract_sections may be helpful here:

https://doc.wikimedia.org/pywikibot/master/api_ref/pywikibot.html?highlight=extract_sections#pywikibot.textlib.extract_sections

Best
xqt

Von meinem iPhone gesendet

Am 05.05.2022 um 00:40 schrieb John <phoenixoverride@gmail.com>:


I know there was code for that in the old 1.0 release. Let me dig it up

On Wed, May 4, 2022 at 6:23 PM Strainu <strainu10@gmail.com> wrote:
Hello fellow bot writers,

I have a problem which must have been solve a million times before,
but I can't find a full solution. I need to add sections to a talk
page in various locations (depending on the page):
# at the top of the page
# before the first section (i.e. at the top, but after some header)
# at the end of the page, before categories etc.

The first case is trivial and I know about pywikibot.textlib.add_text
which covers the third case, but there doesn't seem to be a ready-made
solution for #2. Do you know any?

Thank you,
  Strainu
_______________________________________________
pywikibot mailing list -- pywikibot@lists.wikimedia.org
To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
_______________________________________________
pywikibot mailing list -- pywikibot@lists.wikimedia.org
To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org