Manual talk:Pywikibot/

Jump to navigation Jump to search

About this board

Can we get content from deleted pages?

MrDupin (talkcontribs)

I would like to get content of deleted pages using a bot. Can this script do this? If not, is there any way I can do this?

Thank you.

Dvorapa (talkcontribs)

Users with admin rights on your wiki can do this. If you are not, ask them. If you are, then Special:Undelete page is there for this purpose

MrDupin (talkcontribs)

I am an admin on the particular wiki, but I want to get the content of multiple deleted pages at the same time, automatically.

I think that for normal pages, the 'get' parameter gets the content/text of a page/pages. Is there a way to get the content/text for deleted pages automatically?

Dvorapa (talkcontribs)
Reply to "Can we get content from deleted pages?"
Gamren (talkcontribs)

I wanted a list of all entries in wt:Category:Danish verbs that end in "s". I navigated to ...\pywikibot\core_stable and typed

py listpages -titleregex:'.{2,}s' -cat:Danish verbs

the entries I do get are neither in the category nor end with "s". I got two warnings:

...\data\ UserWarning: Unexpected overlap between action and query submodules: frozenset({'readinglists'})

...\ FamilyMaintenanceWarning: Family name wikimediachapter does not match family module name wikimedia

I am quite able to use ([]). Please tell me if more information is needed.

Octahedron80 (talkcontribs)

How about this:

listpages -titleregex:"s$" -cat:"Danish verbs"

Do not forget quotes. For other messages, I don't know.

PS. You may need to add -ns:0 to filter only main namespace.

Gamren (talkcontribs)

Thank you for answering. That did succeed in filtering out entries that don't end in "s", but it still doesn't care about the category. I tried both with and without quotes around "Danish verbs".__~~~~

Octahedron80 (talkcontribs)

Did you set family to wiktionary and lang to en yet? (or mylang in I tried my answer on PAWS and it had no problem.

Gamren (talkcontribs)

Yes I did, and the articles I was given were from en.wikt.__~~~~

Octahedron80 (talkcontribs)

You may want to try on this:

After log in then make a new terminal. You can start command with

In my opinion, your pywikibot may be out of date, or misconfigured.

Reply to "Parameters not obeyed?"
David.Mirth (talkcontribs)

Sorry for a stupid question, but how do I export the list into a .txt file?

Octahedron80 (talkcontribs)

Append your command with

> somefile.txt

This is common syntax to export output buffer to a file.

Vladis13 (talkcontribs)

This works in Linux, but not in Windows.

Octahedron80 (talkcontribs)

Windows works too. Try it.

Vladis13 (talkcontribs)
Octahedron80 (talkcontribs)
Vladis13 (talkcontribs)
> python listpages -start:s -limit:5 > file.txt
<Unicode redirected stdout>.write: TypeError('write() argument must be str, not bytes',)
Traceback (most recent call last):
  File "", line 270, in <module>
    if not main():
  File "", line 264, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "", line 109, in run_python_file
  File ".\scripts\", line 240, in <module>
  File ".\scripts\", line 223, in main
    pywikibot.stdout(page_fmt.output(num=i, fmt=fmt))
  File "c:\pwb\pywikibot\", line 473, in stdout
    logoutput(text, decoder, newline, STDOUT, **kwargs)
  File "c:\pwb\pywikibot\", line 438, in logoutput
    logger.log(_level, text, extra=context, **kwargs)
  File "c:\python35\lib\logging\", line 1345, in log
    self._log(level, msg, args, **kwargs)
  File "c:\python35\lib\logging\", line 1415, in _log
  File "c:\python35\lib\logging\", line 1425, in handle
  File "c:\python35\lib\logging\", line 1487, in callHandlers
  File "c:\python35\lib\logging\", line 855, in handle
  File "c:\pwb\pywikibot\userinterfaces\", line 503, in emit
    return self.UI.output(text,
  File "c:\pwb\pywikibot\userinterfaces\", line 194, in output
    self._print(text, targetStream)
  File "c:\pwb\pywikibot\userinterfaces\", line 137, in _print
    self.printNonColorized(text, targetStream)
  File "c:\pwb\pywikibot\userinterfaces\", line 129, in printNonColorized
  File "c:\pwb\pywikibot\userinterfaces\", line 254, in write
TypeError: write() argument must be str, not bytes
CRITICAL: Waiting for 1 network thread(s) to finish. Press ctrl-c to abort
Octahedron80 (talkcontribs)

^ It was going to work. I think you have issue with Unicode instead. 😅

David.Mirth (talkcontribs)

I have the same problem as mentioned above, I thought I am doing sth wrong... The problem is probably in Unicode or something, a friend of mine discusses this in a python forum, we'll se :)

Vladis13 (talkcontribs)

I tried change codepage of console via 'chcp 65001' and 'chcp 1252'. The console, the script, and script out is good understand utf-8. (Like python listpages -subcatsr:"Категория:Родившиеся в IX веке".) Python good open|write file|console on utf-8. The error is only when python redirect stdout to file in Windows.

Reply to "Output"
There are no older topics