Compare commits

...

4 Commits

Author SHA1 Message Date
Jeff Carr 4b9be3d24f golang dump of versions 2023-03-25 07:16:08 -05:00
Jeff Carr bd2f756a8c api link 2023-03-25 07:02:48 -05:00
Jeff Carr a5f9f90aab wikipedia API 2023-03-25 07:01:55 -05:00
Jeff Carr f8f4549348 pull FAIL and NOTFAIL 2023-03-25 06:58:58 -05:00
5 changed files with 200 additions and 1 deletions

43
Makefile Normal file
View File

@ -0,0 +1,43 @@
.PHONY: build Zinc
# https://www.mediawiki.org/wiki/API:Main_page
# https://en.wikipedia.org/w/api.php
## incase wp2git doesn't run:
## import sys
## # locale.setlocale(locale.LC_ALL, '')
## lang = sys.getfilesystemencoding()
all:
diff:
cd Wikipedia_Wikipedia_is_succeeding && git whatchanged -p --color-words
install:
reset
./setup.py install --user
test:
reset
wp2git Zinc
Zinc:
reset
wp2git --site https://en.wikipedia.org/w/ Zinc
hershey:
reset
wp2git --site https://en.wikipedia.org/w/ Milton_Hershey_School
NOTFAIL:
reset
wp2git --site https://en.wikipedia.org/w/ "Wikipedia:Wikipedia_is_succeeding"
FAIL:
reset
wp2git --site https://en.wikipedia.org/w/ "Wikipedia:Wikipedia_is_failing"
POLICY:
reset
wp2git --site https://en.wikipedia.org/w/ "Wikipedia:Verifiability"

12
gowikipedia/Makefile Normal file
View File

@ -0,0 +1,12 @@
# lists the changes to the Zinc page:
Zinc:
reset
go run zinc.go
# - ID: 824303964, Parent ID: 824303909, User: 204.122.110.237, UserID: 0, Timestamp: 2018-02-06T15:26:48Z, Comment: /* Physical properties */
# - ID: 824303909, Parent ID: 824303854, User: CLCStudent, UserID: 0, Timestamp: 2018-02-06T15:26:21Z, Comment: Reverted 1 edit by [[Special:Contributions/204.122.110.237|204.122.110.237]] ([[User talk:204.122.110.237|talk]]) to last revision by Onel5969. ([[WP:TW|TW]])
# - ID: 824303854, Parent ID: 824287944, User: 204.122.110.237, UserID: 0, Timestamp: 2018-02-06T15:26:01Z, Comment: /* Zinc(II) compounds */
# - ID: 824287944, Parent ID: 821850427, User: Onel5969, UserID: 0, Timestamp: 2018-02-06T13:21:44Z, Comment: Disambiguating links to [[Poppy]] (link changed to [[Poppy (flower)]]) using [[User:Qwertyytrewqqwerty/DisamAssist|DisamAssist]].
version:
go run getVersion.go

68
gowikipedia/getVersion.go Normal file
View File

@ -0,0 +1,68 @@
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
const wikipediaAPI = "https://en.wikipedia.org/w/api.php"
type QueryResponse struct {
Batchcomplete string `json:"batchcomplete"`
Query struct {
Pages map[string]struct {
Pageid int `json:"pageid"`
Ns int `json:"ns"`
Title string `json:"title"`
Content string `json:"content"`
} `json:"pages"`
} `json:"query"`
}
// - ID: 824303964, Parent ID: 824303909, User: 204.122.110.237, UserID: 0, Timestamp: 2018-02-06T15:26:48Z, Comment: /* Physical properties */
// - ID: 824303909, Parent ID: 824303854, User: CLCStudent, UserID: 0, Timestamp: 2018-02-06T15:26:21Z, Comment: Reverted 1 edit by [[Special:Contributions/204.122.110.237|204.122.110.237]] ([[User talk:204.122.110.237|talk]]) to last revision by Onel5969. ([[WP:TW|TW]])
// - ID: 824303854, Parent ID: 824287944, User: 204.122.110.237, UserID: 0, Timestamp: 2018-02-06T15:26:01Z, Comment: /* Zinc(II) compounds */
// - ID: 824287944, Parent ID: 821850427, User: Onel5969, UserID: 0, Timestamp: 2018-02-06T13:21:44Z, Comment: Disambiguating links to [[Poppy]] (link changed to [[Poppy (flower)]]) using [[User:Qwertyytrewqqwerty/DisamAssist|DisamAssist]].
func main() {
params := url.Values{}
params.Set("action", "query")
params.Set("format", "json")
params.Set("prop", "revisions")
params.Set("titles", "Zinc")
params.Set("rvprop", "content")
params.Set("rvslots", "main")
params.Set("rvlimit", "1")
params.Set("revids", "824287944")
url := fmt.Sprintf("%s?%s", wikipediaAPI, params.Encode())
resp, err := http.Get(url)
if err != nil {
fmt.Printf("Error making request: %v\n", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Printf("Error reading response: %v\n", err)
return
}
var queryResponse QueryResponse
err = json.Unmarshal(body, &queryResponse)
if err != nil {
fmt.Printf("Error unmarshalling JSON: %v\n", err)
return
}
for _, page := range queryResponse.Query.Pages {
fmt.Printf("Content for '%s' (revision ID: 825282998):\n\n", page.Title)
fmt.Println(page.Content)
}
}

76
gowikipedia/zinc.go Normal file
View File

@ -0,0 +1,76 @@
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
const wikipediaAPI = "https://en.wikipedia.org/w/api.php"
type QueryResponse struct {
Batchcomplete string `json:"batchcomplete"`
Continue struct {
RvContinue string `json:"rvcontinue"`
Continue string `json:"continue"`
} `json:"continue"`
Query struct {
Pages map[string]struct {
Pageid int `json:"pageid"`
Ns int `json:"ns"`
Title string `json:"title"`
Revisions []Revision `json:"revisions"`
} `json:"pages"`
} `json:"query"`
}
type Revision struct {
Revid int `json:"revid"`
Parentid int `json:"parentid"`
User string `json:"user"`
Userid int `json:"userid"`
Timestamp string `json:"timestamp"`
Comment string `json:"comment"`
}
func main() {
params := url.Values{}
params.Set("action", "query")
params.Set("format", "json")
params.Set("prop", "revisions")
params.Set("titles", "Zinc")
params.Set("rvlimit", "max")
params.Set("rvprop", "timestamp|user|comment|ids")
url := fmt.Sprintf("%s?%s", wikipediaAPI, params.Encode())
resp, err := http.Get(url)
if err != nil {
fmt.Printf("Error making request: %v\n", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Printf("Error reading response: %v\n", err)
return
}
var queryResponse QueryResponse
err = json.Unmarshal(body, &queryResponse)
if err != nil {
fmt.Printf("Error unmarshalling JSON: %v\n", err)
return
}
for _, page := range queryResponse.Query.Pages {
fmt.Printf("Revisions for '%s':\n", page.Title)
for _, revision := range page.Revisions {
fmt.Printf("- ID: %d, Parent ID: %d, User: %s, UserID: %d, Timestamp: %s, Comment: %s\n",
revision.Revid, revision.Parentid, revision.User, revision.Userid, revision.Timestamp, revision.Comment)
}
}
}

View File

@ -1,3 +1,3 @@
# Do not edit this file, wp2git versioning is governed by git tags # Do not edit this file, wp2git versioning is governed by git tags
__version__="2.0" __version__="2.0.dev1+g8d8fdc2"