Wikipedia talk:WikiProject Australian rules football/Cleanup listing data
Appearance
This project page does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||
|
Detailed instructions as posted User:Smallman12q/Scripts/cleanuplistingtowiki in February 2012.
Automated "Toolserver to Wikipedia Cleanup list" instructions
[edit]The following is a visual basic script for adding cleanuplistings to the wiki for a specific project.
The script requires that you have XP (or higher) with VBS installed (this is installed on most Windows machines), and IE6+. For large projects (70k articles), it will take 250MB+ of RAM (VBS isn't the most efficient, and neither is IE).
Setup
[edit]- Open notepad
- Copy and paste the code below into notepad
- Add your username, password, project, and project page.
- In notepad, select File->Save as and select "All files" at "File Save as Type"
- Enter the title cleanuplistingtowiki.vbs and select save in a directory.
Usage
[edit]- Double-click cleanuplistingtowiki.vbs. It will open an IE window, log you into Wikipedia, and create a preview of the table.
- Select 'Save Page' from the preview. Done!
If you have any questions, please ask at my talk page at: User talk:Smallman12q
Source
[edit]Option Explicit
Dim user, userpass, project, projectpage
user = "XXXXXXXX"'username
userpass = "XXXXXXX"'password
project = "Australian rules football"'As called on toolserver
projectpage = "Wikipedia:WikiProject Australian rules football/Cleanup listing data"
'To do
'* Check login success
'* Wscript.Echo progress
'* Error Handling
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''
''''''Do Not edit below'''''''''''
Dim oIE
Set oIE = CreateObject("InternetExplorer.application")
With oIE
.Visible = True
.navigate ("http://toolserver.org/~svick/CleanupListing/CleanupListing.php?project=" + project + "&format=csv")
End With
Do Until oIE.ReadyState = 4 'readystate 4 = done loading
wscript.sleep 200
Loop
'Split by lines
Dim arrLines, lines, strLinecount
arrLines = Split(oIE.Document.body.innerText,vbCrLf)
lines = UBound(arrLines)
strLinecount = -1
Dim articles()
ReDim articles(lines)
Class Article
Public Name
Public Importance
Public Clas 'Class is reserved keyword
Public Count
Public Categories
Public sCategories
End Class
'Process eachline
Dim strLine, pieces
For Each strLine in arrLines
strLine = Mid(Left(strLine,Len(strLine) - 1),2) 'Remove first and last "
pieces = Split(strLine,Chr(34) & "," & Chr(34)) 'Split by ","
if strLinecount=-1 Then 'Skip 1st line
strLinecount=0
Else
'Add article & its cats to array
Set articles(strLinecount) = New Article
With articles(strLinecount)
.Name = "[[" + pieces(0) + "]]"
.Importance = pieces(1)
.Clas = pieces(2)
.Count = pieces(3)
'.Categories = Split(pieces(4),",")
.sCategories = pieces(4) 'String alone, more mem though
End With
strLinecount = strLinecount + 1
End If
Next
'Make wikitable
dim ts 'wikitable
set ts=new FStringCat
ts.push("{| class=""wikitable sortable"" border=""1""" + vbCrLf &_
"|+ [http://toolserver.org/~svick/CleanupListing/CleanupListing.php?project=" + Escape(project) + " Cleanup by articles] posted " + CStr(DateValue(Now)) + vbCrLf &_
"!#" + vbCrLf &_
"!Article" + vbCrLf &_
"!Importance" + vbCrLf &_
"!Class" + vbCrLf &_
"!Count" + vbCrLf &_
"!Categories" + vbCrLf &_
"|-" + vbCrLf)
Dim i
For i = 0 to (lines - 1)
ts.push( "|" + CStr(i + 1) + vbCrLf &_
"|" & articles(i).Name + vbCrLf &_
"|" & articles(i).Importance + vbCrLf &_
"|" & articles(i).Clas + vbCrLf &_
"|" & articles(i).Count + vbCrLf &_
"|" & articles(i).sCategories + vbCrLf &_
"|-" + vbCrLf)
Next
ts.push("|}")
Erase articles
'Wikitable done
'login
With oIE
.Visible = True
.navigate ("https://en.wikipedia.org/w/index.php?title=Special:UserLogin")'&returnto=" + projectpage)
End With
Do Until oIE.ReadyState = 4 'readystate 4 = done loading
wscript.sleep 200
Loop
With oIE.Document.forms("userlogin")
.wpName.Value = user
.wpPassword.Value = userpass
.submit
End With
'Go to edit page and do preview
With oIE
.Visible = True
.navigate ("https://en.wikipedia.org/w/index.php?title=" + projectpage + "&action=edit")
End With
Do Until oIE.ReadyState = 4 'readystate 4 = done loading
wscript.sleep 200
Loop
With oIE.Document.forms("editform")
.wpTextbox1.Value = ts.ToString()
.wpPreview.Click
End With
'The standard looped concatenation is slooooooooooooow, this will make it 1000x faster
'http://support.microsoft.com/kb/170964
'http://www.codeproject.com/Articles/18397/High-Speed-String-Concatenation-Using-VBScript
'This portion is under the http://www.codeproject.com/info/cpol10.aspx The Code Project Open License (CPOL)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
class XLink
public datum
public nextXLink
private sub Class_Initialize
set nextXLink=nothing
datum=""
end sub
end class
class FStringCat
private sp
private ep
private l
private accum
private sub Class_Initialize
l=0
accum=""
set sp=nothing
end sub
public sub push(what)
accum=accum & what
if len(accum)>2800 then
if(sp is nothing) then
set ep=new XLink
set sp=ep
else
dim oep
set oep=ep
set ep=new XLink
set oep.nextXLink=ep
end if
ep.datum=accum
accum=""
l=l+1
end if
end sub
public function toString()
if l=0 then
toString=accum
exit function
end if
ep.datum=ep.datum & accum
while l>1
dim ptr
set ptr=sp
dim nsp
set nsp=new XLink
dim nep
set nep=nsp
dim nl
nl=0
while not (ptr is nothing)
if nep.datum="" then
nep.datum=ptr.datum
nl=nl+1
else
if ptr.datum<>"" then nep.datum=nep.datum & ptr.datum
set nep.nextXLink=new XLink
set nep=nep.nextXLink
end if
set ptr=ptr.nextXLink
wend
set sp=nsp
set ep=nep
l=nl
wend
toString=sp.datum
end function
end class