wikipedia: Pass API query parameters as params
dict in requests.get().
This commit is contained in:
parent
8654ce53db
commit
bccbda49f2
|
@ -1,6 +1,12 @@
|
|||
{
|
||||
"request": {
|
||||
"api_url":"https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=%23&format=json"
|
||||
"api_url":"https://en.wikipedia.org/w/api.php",
|
||||
"params": {
|
||||
"action": "query",
|
||||
"list": "search",
|
||||
"srsearch": "#",
|
||||
"format": "json"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"data": {
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
{
|
||||
"request": {
|
||||
"api_url":"https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=sssssss%20kkkkk&format=json"
|
||||
"api_url":"https://en.wikipedia.org/w/api.php",
|
||||
"params": {
|
||||
"action": "query",
|
||||
"list": "search",
|
||||
"srsearch": "sssssss kkkkk",
|
||||
"format": "json"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"data": {
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
{
|
||||
"request": {
|
||||
"api_url":"https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=The%20sky%20is%20blue&format=json"
|
||||
"api_url":"https://en.wikipedia.org/w/api.php",
|
||||
"params": {
|
||||
"action": "query",
|
||||
"list": "search",
|
||||
"srsearch": "The sky is blue",
|
||||
"format": "json"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"data": {
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
{
|
||||
"request": {
|
||||
"api_url":"https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=123&format=json"
|
||||
"api_url":"https://en.wikipedia.org/w/api.php",
|
||||
"params": {
|
||||
"action": "query",
|
||||
"list": "search",
|
||||
"srsearch": "123",
|
||||
"format": "json"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"data": {
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
{
|
||||
"request": {
|
||||
"api_url":"https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=happy&format=json"
|
||||
"api_url":"https://en.wikipedia.org/w/api.php",
|
||||
"params": {
|
||||
"action": "query",
|
||||
"list": "search",
|
||||
"srsearch": "happy",
|
||||
"format": "json"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"data": {
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
|
||||
{
|
||||
"request": {
|
||||
"api_url":"https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=Zulip&format=json"
|
||||
"api_url":"https://en.wikipedia.org/w/api.php",
|
||||
"params": {
|
||||
"action": "query",
|
||||
"list": "search",
|
||||
"srsearch": "Zulip",
|
||||
"format": "json"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"data": {
|
||||
|
|
|
@ -47,11 +47,15 @@ class WikipediaHandler(object):
|
|||
if query == '':
|
||||
return help_text
|
||||
|
||||
query_wiki_link = ('https://en.wikipedia.org/w/api.php?action=query&'
|
||||
'list=search&srsearch=%s&format=json'
|
||||
% (urllib.parse.quote(query),))
|
||||
query_wiki_url = 'https://en.wikipedia.org/w/api.php'
|
||||
query_wiki_params = dict(
|
||||
action='query',
|
||||
list='search',
|
||||
srsearch=query,
|
||||
format='json'
|
||||
)
|
||||
try:
|
||||
data = requests.get(query_wiki_link)
|
||||
data = requests.get(query_wiki_url, params=query_wiki_params)
|
||||
|
||||
except requests.exceptions.RequestException:
|
||||
logging.error('broken link')
|
||||
|
|
Loading…
Reference in a new issue