anon = '89.134.24.79/16'
user = pywikibot.User(site, anon)
for contrib in user.contributions():
print(contrib[1])
This makes nothing.
(There is a massive vandal from a range, and I want to hide all the
inappropriate contents made by him.)
--
Bináris
*TL;DR*: we can mass hide vandal revisions from pages histories, e.g.
obscene images and edit comments.
Of course, this needs admin rights.
It is easy to mass hide revisions from the history of one page without bot,
just click checkboxes. But it is tiring, if several pages are involved.
I wrote a script that is not ready to publish, and I won't show it for the
vandal, and needs manual editing. But I can send it in a private mail to
those who are interested.
The API documentation is here:
https://www.mediawiki.org/wiki/API:Revisiondelete
But it is not complete. I learned on my own that multiple revids may
concern the same page. We don't have to write the title into the request,
but must group the revisions by page.
The required format is e.g. 27009438|27009402|27009353|27009335|27009151
with pipe, all ids belong to the same page, otherwise they won't all be
processed, just the first page. This is an undocumentetd feature. :-)
Sample code fragment (run with -user:myadminaccount):
hide = 'content|comment|user' # Just to show the syntax, keep what you need
reason = 'Vandalism'
def gen() -> Iterator[str]:
"""Yield ids to hide in the above form, page by page. Here comes your
work."""
yield' 27009438|27009402|27009353|27009335|27009151' # Example
token = site.get_tokens(['csrf']).get('csrf') # get a single token
for ids in gen():
params = {'action': 'revisiondelete',
'type': 'revision',
'ids': ids,
'hide': hide,
'token': token,
'reason': reason,
}
request = site.simple_request(**params)
request.submit()
To get the ids use for contrib in user.contributions():
contrib[0] will be the page object, while contrib[1] the revision id for
each contribution.
--
Bináris
If I do:
wikicode = mwparserfromhell.parse("This is\n__TOC__\nan article.")
I get back a single Text node. For what I'm doing, it would be really
convenient to have the __TOC__ be parsed as it's own node, i.e. instead
of a single Text node with 'This is\n__TOC__\nan article.', I'd like to
get 3 Text nodes, with 'This is\n', '__TOC__', '\nan article.']
The best I've come up with so far is to pre-process the text to insert
HTML comments around the __TOC__, but that's really ugly for so many
reasons. The next best I've come up with is to post-process the nodes
to manually split any Text node that has __TOC__ in it into 2 or 3 Text
nodes, but that's really ugly for so many other reasons. Anybody have
any better ideas?
Hi pywikibot experts
I am using the following command string (Python 3.12, Windows 11):
python pwb.py upload <full source file path on local drive> -ignorewarn
-noverify -prefix:WA00 -descfile:full description file path on local drive>
upload.py asks me to confirm the target file name. I would prefer a
completely silent upload without the need for confirmation.
Is there a "-silent" flag that I can use?
Also, I noticed I can only execute commands like "python pwb.py ....." if I
am in the folder
C:\Users\<myusername>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages
This folder is in my "path" (see below).
How can I make pwb.py accessible from other folders?
Thanks
James Trevelyan
Path=
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;
C:\Program Files (x86)\Common
Files\Intel\SharedLibraries\redist\intel64\compiler;
C:\WINDOWS\system32;C:\WINDOWS;
C:\WINDOWS\System32\Wbem;
C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\WINDOWS\System32\OpenSSH\;
C:\Program Files\dotnet\;
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;
C:\Users\<myusername>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;
C:\Users\<myusername>\AppData\Local\Microsoft\WindowsApps;
M: +61 402 481 167 (WhatsApp) E: James.Trevelyan(a)uwa.edu.au
33 Brockman Ave, Dalkeith WA 6009
0402 48 1167
Hi,
given a category c and a page p, p is listed in c.articles(recurse=True)
But is shouldn't... And I don't know the depth of it.
Is there a simple way to find a path between them, and guess, why is the
page in the category?
(I spent 10 minutes with manual trying, total fail.)
--
Bináris
The docs for BasePage.get() say:
pywikibot.exceptions.IsRedirectPageError – The page is a redirect. The argument of the exception is the title of the page it redirects to.
but that doesn't seem to be what's actually happening:
> from pywikibot import Site, Page
> from pywikibot.exceptions import IsRedirectPageError
>
> site = Site("en")
>
> page = Page(site, "Template:shortdescription")
> try:
> print(page.get())
> except IsRedirectPageError as ex:
> print(f"{ex.args=}")
prints
> ex.args=(Page('Template:Shortdescription'),)
Am I just not understanding the doc correctly?
If I've got a Node out of Wikicode.filter(), is there a way to map that back to a location in the original parsed wikitext? Ideally, character offsets for the start and end of the text that makes up the Node.
I'm trying to single-step through pywikibot using vscode. I've got:
certifi==2024.2.2
charset-normalizer==3.3.2
idna==3.6
iniconfig==2.0.0
mwparserfromhell==0.6.6
packaging==23.2
pluggy==1.4.0
pytest==8.0.2
pytest-mock==3.12.0
pywikibot==8.6.0
requests==2.31.0
urllib3==2.2.1
vscode: Version: 1.87.1
MacOS Ventura 13.6.4
Python 3.11.8
I'm getting a bunch of Pylance errors (warnings?) _basepage.py of the form:
Variable not allowed in type expression
It seems to be complaining about the "Dict" in:
def protection(self) -> Dict[str, Tuple[str, str]]:
Any idea what's going on?
Dear Pywikibot Contributors,
I trust this message finds you well. My name is Abdulrhman Adel, and I'm
enthusiastic about the prospect of contributing to the Pywikibot project.
In my journey as a developer, I've had the opportunity to work on various
projects, including several Python projects developed for hackathons. One
of my most significant achievements is the creation of the A.I.S.L a Sign
Language Assistant. This bot was specifically designed to assist
individuals with sign language.
Pywikibot's role as a Python library and automation tool, developed for
Wikipedia, has captured my interest and I'm eager to contribute my skills
and insights to enhance Pywikibot's capabilities.
Feel free to explore my GitHub profile
<https://github.com/abdulrhman-adel/>and my repositories to gain insight
into my coding style and previous contributions.
Having reviewed the Pywikibot documentation and contributor guidelines, I
am enthusiastic about the prospect of getting involved. Could you please
provide guidance on the next steps or point me to tasks suitable for
newcomers?
Thank you for your time and consideration. I am looking forward to the
opportunity to collaborate with the Pywikibot community.
Best regards,
Abdulrhman Adel
Hi.
I launch it with the command:
python pwb.py interwiki -start:!
And the work will stop with the error:
Error: [[en:]]: The requested page title is empty or contains only the name of a namespace.
I've searched all over the wiki and can't find what article it's in [[en:]].
There's a last line on the screen,
.======Post-processing [[es:Historia y mundo]]====== ,
but it's not the same article
How can I find out which article is causing my work to stop?
-
in interwiki-dumps/dragonsdogma-es.txt 126 records.
Log:
2024-02-19 11:02:36 interwiki.py, 1431 in post_processing: INFO ======Post-processing [[es:Ignitia]]======
2024-02-19 11:02:36 interwiki.py, 1431 in post_processing: INFO ======Post-processing [[es:Historia y mundo]]======
2024-02-19 11:02:36 interwiki.py, 1431 in post_processing: INFO ======Post-processing [[es:Historia y mundo]]======
2024-02-19 11:02:36 _generators.py, 265 in __init__: VERBOSE PropertyGenerator: multiple requested query modules support limits; using the first such module 'revisions' of ['revisions', 'info', 'categoryinfo', 'templates', 'langlinks', 'pageprops']
2024-02-19 11:02:36 _generators.py, 265 in __init__: VERBOSE PropertyGenerator: multiple requested query modules support limits; using the first such module 'revisions' of ['revisions', 'info', 'categoryinfo', 'templates', 'langlinks', 'pageprops']
2024-02-19 11:02:36 _generators.py, 408 in _update_limit: DEBUG PropertyGenerator: Set query_limit to 5000.
2024-02-19 11:02:36 _generators.py, 408 in _update_limit: DEBUG PropertyGenerator: Set query_limit to 5000.
2024-02-19 11:02:36 _generators.py, 167 in preloadpages: INFO Retrieving 50 pages from dragonsdogma:en.
2024-02-19 11:02:36 _generators.py, 167 in preloadpages: INFO Retrieving 50 pages from dragonsdogma:en.
2024-02-19 11:02:36 _requests.py, 660 in _get_request_params: DEBUG API request to dragonsdogma:en (uses get: False):
Headers: {'Content-Type': 'application/x-www-form-urlencoded'}
URI: '/api.php'
Body: 'prop=revisions%7Cinfo%7Ccategoryinfo%7Ctemplates%7Clanglinks%7Cpageprops&action=query&indexpageids=&continue=&tllimit=5000&lllimit=5000&rvslots=%2A&titles=Phantasm%7CEsperaunce%7CPhantom%7CSkeleton%7CSkeleton+Brute%7CBarn%7CEstevon%7CStilettos%7CGolden+Stilettos%7CAneled+Stilettos%7CStage+6%7CPost-Game%7CStage+1%7CA+Soldier%27s+Survey%7CSerenity+Extract%7CVigor+Extract%7CFalchion%7CSpecter%7CFedel%7CFeste%7CBeast-Steak%7CRotten+Beast-Steak%7CGransys+Flamberge%7CFlavian%7CPoison+Arrow%7COil+Arrow%7CThornflower%7CJasper+Blossom%7CLava+Flower%7CCapeflower%7CNoonflower%7CWindmill+Flower%7CGodsthrone+Blossom%7CGrandblossom%7CWilted+Blossom%7CKept+Wilted+Blossom%7CLoneflower%7C%7CStout+Undead%7CFournival%7CWakestone+Shard%7CFredro%7CFire%7CFont+of+Constitution%7CFont+of+Vigor%7CBlack+Eyeglasses%7CDominion+Claw%7CDevil%27s+Nail%7CGarvin%7CSeabird&rvprop=comment%7Ccontentmodel%7Cflags%7Cids%7Cparsedcomment%7Csha1%7Csize%7Ctags%7Ctimestamp%7Cuser%7Cuserid%7Ccontent%7Croles&meta=userinfo&uiprop=blockinfo%7Chasmsg&maxlag=5&format=json'
2024-02-19 11:02:36 _requests.py, 660 in _get_request_params: DEBUG API request to dragonsdogma:en (uses get: False):
Headers: {'Content-Type': 'application/x-www-form-urlencoded'}
URI: '/api.php'
Body: 'prop=revisions%7Cinfo%7Ccategoryinfo%7Ctemplates%7Clanglinks%7Cpageprops&action=query&indexpageids=&continue=&tllimit=5000&lllimit=5000&rvslots=%2A&titles=Phantasm%7CEsperaunce%7CPhantom%7CSkeleton%7CSkeleton+Brute%7CBarn%7CEstevon%7CStilettos%7CGolden+Stilettos%7CAneled+Stilettos%7CStage+6%7CPost-Game%7CStage+1%7CA+Soldier%27s+Survey%7CSerenity+Extract%7CVigor+Extract%7CFalchion%7CSpecter%7CFedel%7CFeste%7CBeast-Steak%7CRotten+Beast-Steak%7CGransys+Flamberge%7CFlavian%7CPoison+Arrow%7COil+Arrow%7CThornflower%7CJasper+Blossom%7CLava+Flower%7CCapeflower%7CNoonflower%7CWindmill+Flower%7CGodsthrone+Blossom%7CGrandblossom%7CWilted+Blossom%7CKept+Wilted+Blossom%7CLoneflower%7C%7CStout+Undead%7CFournival%7CWakestone+Shard%7CFredro%7CFire%7CFont+of+Constitution%7CFont+of+Vigor%7CBlack+Eyeglasses%7CDominion+Claw%7CDevil%27s+Nail%7CGarvin%7CSeabird&rvprop=comment%7Ccontentmodel%7Cflags%7Cids%7Cparsedcomment%7Csha1%7Csize%7Ctags%7Ctimestamp%7Cuser%7Cuserid%7Ccontent%7Croles&meta=userinfo&uiprop=blockinfo%7Chasmsg&maxlag=5&format=json'
2024-02-19 11:02:37 _requests.py, 779 in _relogin: ERROR Logged in as '95.25.124.157' instead of 'Vzhik-bot'. Forcing re-login.
2024-02-19 11:02:37 _requests.py, 779 in _relogin: ERROR Logged in as '95.25.124.157' instead of 'Vzhik-bot'. Forcing re-login.
2024-02-19 11:02:37 http.py, 89 in load: DEBUG Loaded cookies for user Vzhik-bot from file.
2024-02-19 11:02:37 http.py, 89 in load: DEBUG Loaded cookies for user Vzhik-bot from file.
2024-02-19 11:02:37 _requests.py, 660 in _get_request_params: DEBUG API request to dragonsdogma:en (uses get: True):
Headers: {'Content-Type': 'application/x-www-form-urlencoded'}
URI: '/api.php?action=query&meta=userinfo&uiprop=blockinfo%7Cgroups%7Chasmsg%7Cratelimits%7Crights&formatversion=2&maxlag=5&format=json'
Body: None
2024-02-19 11:02:37 _requests.py, 660 in _get_request_params: DEBUG API request to dragonsdogma:en (uses get: True):
Headers: {'Content-Type': 'application/x-www-form-urlencoded'}
URI: '/api.php?action=query&meta=userinfo&uiprop=blockinfo%7Cgroups%7Chasmsg%7Cratelimits%7Crights&formatversion=2&maxlag=5&format=json'
Body: None
2024-02-19 11:02:37 _requests.py, 660 in _get_request_params: DEBUG API request to dragonsdogma:en (uses get: False):
Headers: {'Content-Type': 'application/x-www-form-urlencoded'}
URI: '/api.php'
Body: 'prop=revisions%7Cinfo%7Ccategoryinfo%7Ctemplates%7Clanglinks%7Cpageprops&action=query&indexpageids=&continue=&tllimit=5000&lllimit=5000&rvslots=%2A&titles=Phantasm%7CEsperaunce%7CPhantom%7CSkeleton%7CSkeleton+Brute%7CBarn%7CEstevon%7CStilettos%7CGolden+Stilettos%7CAneled+Stilettos%7CStage+6%7CPost-Game%7CStage+1%7CA+Soldier%27s+Survey%7CSerenity+Extract%7CVigor+Extract%7CFalchion%7CSpecter%7CFedel%7CFeste%7CBeast-Steak%7CRotten+Beast-Steak%7CGransys+Flamberge%7CFlavian%7CPoison+Arrow%7COil+Arrow%7CThornflower%7CJasper+Blossom%7CLava+Flower%7CCapeflower%7CNoonflower%7CWindmill+Flower%7CGodsthrone+Blossom%7CGrandblossom%7CWilted+Blossom%7CKept+Wilted+Blossom%7CLoneflower%7C%7CStout+Undead%7CFournival%7CWakestone+Shard%7CFredro%7CFire%7CFont+of+Constitution%7CFont+of+Vigor%7CBlack+Eyeglasses%7CDominion+Claw%7CDevil%27s+Nail%7CGarvin%7CSeabird&rvprop=comment%7Ccontentmodel%7Cflags%7Cids%7Cparsedcomment%7Csha1%7Csize%7Ctags%7Ctimestamp%7Cuser%7Cuserid%7Ccontent%7Croles&meta=userinfo&uiprop=blockinfo%7Chasmsg&maxlag=5&format=json'
2024-02-19 11:02:37 _requests.py, 660 in _get_request_params: DEBUG API request to dragonsdogma:en (uses get: False):
Headers: {'Content-Type': 'application/x-www-form-urlencoded'}
URI: '/api.php'
Body: 'prop=revisions%7Cinfo%7Ccategoryinfo%7Ctemplates%7Clanglinks%7Cpageprops&action=query&indexpageids=&continue=&tllimit=5000&lllimit=5000&rvslots=%2A&titles=Phantasm%7CEsperaunce%7CPhantom%7CSkeleton%7CSkeleton+Brute%7CBarn%7CEstevon%7CStilettos%7CGolden+Stilettos%7CAneled+Stilettos%7CStage+6%7CPost-Game%7CStage+1%7CA+Soldier%27s+Survey%7CSerenity+Extract%7CVigor+Extract%7CFalchion%7CSpecter%7CFedel%7CFeste%7CBeast-Steak%7CRotten+Beast-Steak%7CGransys+Flamberge%7CFlavian%7CPoison+Arrow%7COil+Arrow%7CThornflower%7CJasper+Blossom%7CLava+Flower%7CCapeflower%7CNoonflower%7CWindmill+Flower%7CGodsthrone+Blossom%7CGrandblossom%7CWilted+Blossom%7CKept+Wilted+Blossom%7CLoneflower%7C%7CStout+Undead%7CFournival%7CWakestone+Shard%7CFredro%7CFire%7CFont+of+Constitution%7CFont+of+Vigor%7CBlack+Eyeglasses%7CDominion+Claw%7CDevil%27s+Nail%7CGarvin%7CSeabird&rvprop=comment%7Ccontentmodel%7Cflags%7Cids%7Cparsedcomment%7Csha1%7Csize%7Ctags%7Ctimestamp%7Cuser%7Cuserid%7Ccontent%7Croles&meta=userinfo&uiprop=blockinfo%7Chasmsg&maxlag=5&format=json'
2024-02-19 11:02:37 _generators.py, 556 in _get_resultdata: DEBUG PropertyGenerator received ['-1', '23169', '11401', '5924', '3728', '10379', '14276', '56380', '54288', '38125', '4511', '38131', '8826', '2185', '39294', '5125', '37264', '42755', '5141', '6382', '5127', '13315', '4630', '28098', '54233', '6258', '14417', '39695', '20077', '11197', '22782', '2799', '2294', '23395', '7701', '39022', '3099', '25149', '2150', '50690', '3110', '70778', '70981', '3682', '2795', '6256', '25148', '8483', '6250', '12451']; limit=-1
2024-02-19 11:02:37 _generators.py, 556 in _get_resultdata: DEBUG PropertyGenerator received ['-1', '23169', '11401', '5924', '3728', '10379', '14276', '56380', '54288', '38125', '4511', '38131', '8826', '2185', '39294', '5125', '37264', '42755', '5141', '6382', '5127', '13315', '4630', '28098', '54233', '6258', '14417', '39695', '20077', '11197', '22782', '2799', '2294', '23395', '7701', '39022', '3099', '25149', '2150', '50690', '3110', '70778', '70981', '3682', '2795', '6256', '25148', '8483', '6250', '12451']; limit=-1
2024-02-19 11:02:37 _generators.py, 170 in preloadpages: DEBUG Preloading {'title': '', 'invalidreason': 'The requested page title is empty or contains only the name of a namespace.', 'invalid': ''}
2024-02-19 11:02:37 _generators.py, 170 in preloadpages: DEBUG Preloading {'title': '', 'invalidreason': 'The requested page title is empty or contains only the name of a namespace.', 'invalid': ''}
2024-02-19 11:02:37 logging.py, 337 in exception: ERROR [[en:]]: The requested page title is empty or contains only the name of a namespace.
Traceback (most recent call last):
File "E:\install\wiki\pywikibot\Pywikibot 8.6.0\scripts\interwiki.py", line 2376, in main
bot.run()
File "E:\install\wiki\pywikibot\Pywikibot 8.6.0\scripts\interwiki.py", line 2022, in run
self.queryStep()
File "E:\install\wiki\pywikibot\Pywikibot 8.6.0\scripts\interwiki.py", line 1999, in queryStep
self.oneQuery()
File "E:\install\wiki\pywikibot\Pywikibot 8.6.0\scripts\interwiki.py", line 1987, in oneQuery
for _ in gen:
File "E:\install\wiki\pywikibot\Pywikibot 8.6.0\pywikibot\site\_generators.py", line 197, in preloadpages
api.update_page(page, pagedata, rvgen.props)
File "E:\install\wiki\pywikibot\Pywikibot 8.6.0\pywikibot\data\api\_generators.py", line 973, in update_page
_update_pageid(page, pagedict)
File "E:\install\wiki\pywikibot\Pywikibot 8.6.0\pywikibot\data\api\_generators.py", line 872, in _update_pageid
raise InvalidTitleError(f"{page}: {pagedict['invalidreason']}")
pywikibot.exceptions.InvalidTitleError: [[en:]]: The requested page title is empty or contains only the name of a namespace.
2024-02-19 11:02:37 logging.py, 337 in exception: ERROR [[en:]]: The requested page title is empty or contains only the name of a namespace.
Traceback (most recent call last):
File "E:\install\wiki\pywikibot\Pywikibot 8.6.0\scripts\interwiki.py", line 2376, in main
bot.run()
File "E:\install\wiki\pywikibot\Pywikibot 8.6.0\scripts\interwiki.py", line 2022, in run
self.queryStep()
File "E:\install\wiki\pywikibot\Pywikibot 8.6.0\scripts\interwiki.py", line 1999, in queryStep
self.oneQuery()
File "E:\install\wiki\pywikibot\Pywikibot 8.6.0\scripts\interwiki.py", line 1987, in oneQuery
for _ in gen:
File "E:\install\wiki\pywikibot\Pywikibot 8.6.0\pywikibot\site\_generators.py", line 197, in preloadpages
api.update_page(page, pagedata, rvgen.props)
File "E:\install\wiki\pywikibot\Pywikibot 8.6.0\pywikibot\data\api\_generators.py", line 973, in update_page
_update_pageid(page, pagedict)
File "E:\install\wiki\pywikibot\Pywikibot 8.6.0\pywikibot\data\api\_generators.py", line 872, in _update_pageid
raise InvalidTitleError(f"{page}: {pagedict['invalidreason']}")
pywikibot.exceptions.InvalidTitleError: [[en:]]: The requested page title is empty or contains only the name of a namespace.
2024-02-19 11:02:37 __init__.py, 347 in _flush: DEBUG _flush() called
2024-02-19 11:02:37 __init__.py, 347 in _flush: DEBUG _flush() called
2024-02-19 11:02:37 __init__.py, 397 in _flush: VERBOSE Dropped throttle(s).
2024-02-19 11:02:37 __init__.py, 397 in _flush: VERBOSE Dropped throttle(s).
2024-02-19 11:02:37 http.py, 119 in flush: VERBOSE Closing network session.
2024-02-19 11:02:37 http.py, 119 in flush: VERBOSE Closing network session.