Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GET rather than POST for API requests #349

Merged
merged 1 commit into from
Feb 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions dumpgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def getNamespacesAPI(config={}, session=None):
namespaces = config['namespaces']
namespacenames = {0: ''} # main is 0, no prefix
if namespaces:
r = session.post(
r = session.get(
url=config['api'],
params={
'action': 'query',
Expand Down Expand Up @@ -271,7 +271,7 @@ def getPageTitlesAPI(config={}, session=None):
retryCount = 0
while retryCount < config["retries"]:
try:
r = session.post(url=config['api'], data=params, timeout=30)
r = session.get(url=config['api'], params=params, timeout=30)
break
except ConnectionError as err:
print "Connection error: %s" % (str(err),)
Expand Down Expand Up @@ -488,7 +488,7 @@ def getXMLHeader(config={}, session=None):
try:
if config['api']:
print "Trying the local name for the Special namespace instead"
r = session.post(
r = session.get(
url=config['api'],
params={
'action': 'query',
Expand Down Expand Up @@ -1158,7 +1158,7 @@ def getImageNamesAPI(config={}, session=None):
'format': 'json',
'ailimit': 500}
# FIXME Handle HTTP Errors HERE
r = session.post(url=config['api'], params=params, timeout=30)
r = session.get(url=config['api'], params=params, timeout=30)
handleStatusCode(r)
jsonimages = getJSON(r)
delay(config=config, session=session)
Expand Down Expand Up @@ -1216,7 +1216,7 @@ def getImageNamesAPI(config={}, session=None):
'iiprop': 'user|url',
'format': 'json'}
# FIXME Handle HTTP Errors HERE
r = session.post(url=config['api'], params=params, timeout=30)
r = session.get(url=config['api'], params=params, timeout=30)
handleStatusCode(r)
jsonimages = getJSON(r)
delay(config=config, session=session)
Expand Down Expand Up @@ -1736,9 +1736,9 @@ def checkAPI(api=None, session=None):
# handle redirects
for i in range(4):
print 'Checking API...', api
r = session.post(
r = session.get(
url=api,
data={
params={
'action': 'query',
'meta': 'siteinfo',
'format': 'json'},
Expand Down Expand Up @@ -2074,7 +2074,7 @@ def saveSiteInfo(config={}, session=None):
print 'Downloading site info as siteinfo.json'

# MediaWiki 1.13+
r = session.post(
r = session.get(
url=config['api'],
params={
'action': 'query',
Expand All @@ -2085,7 +2085,7 @@ def saveSiteInfo(config={}, session=None):
timeout=10)
# MediaWiki 1.11-1.12
if not 'query' in getJSON(r):
r = session.post(
r = session.get(
url=config['api'],
params={
'action': 'query',
Expand All @@ -2095,7 +2095,7 @@ def saveSiteInfo(config={}, session=None):
timeout=10)
# MediaWiki 1.8-1.10
if not 'query' in getJSON(r):
r = session.post(
r = session.get(
url=config['api'],
params={
'action': 'query',
Expand Down