stack_overflow: Pass API query parameters as params
dict in requests.get().
This commit is contained in:
parent
a38917723a
commit
86ffbb2b4a
|
@ -1,6 +1,12 @@
|
|||
{
|
||||
"request": {
|
||||
"api_url":"http://api.stackexchange.com/2.2/search/advanced?order=desc&sort=relevance&site=stackoverflow&title=narendra"
|
||||
"api_url":"http://api.stackexchange.com/2.2/search/advanced",
|
||||
"params": {
|
||||
"order": "desc",
|
||||
"sort": "relevance",
|
||||
"site": "stackoverflow",
|
||||
"title": "narendra"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"data": {
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
{
|
||||
"request": {
|
||||
"api_url":"http://api.stackexchange.com/2.2/search/advanced?order=desc&sort=relevance&site=stackoverflow&title=what%20is%20flutter"
|
||||
"api_url":"http://api.stackexchange.com/2.2/search/advanced",
|
||||
"params": {
|
||||
"order": "desc",
|
||||
"sort": "relevance",
|
||||
"site": "stackoverflow",
|
||||
"title": "what is flutter"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"data": {
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
{
|
||||
"request": {
|
||||
"api_url":"http://api.stackexchange.com/2.2/search/advanced?order=desc&sort=relevance&site=stackoverflow&title=113"
|
||||
"api_url":"http://api.stackexchange.com/2.2/search/advanced",
|
||||
"params": {
|
||||
"order": "desc",
|
||||
"sort": "relevance",
|
||||
"site": "stackoverflow",
|
||||
"title": "113"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"data": {
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
{
|
||||
"request": {
|
||||
"api_url":"http://api.stackexchange.com/2.2/search/advanced?order=desc&sort=relevance&site=stackoverflow&title=restful"
|
||||
"api_url":"http://api.stackexchange.com/2.2/search/advanced",
|
||||
"params": {
|
||||
"order": "desc",
|
||||
"sort": "relevance",
|
||||
"site": "stackoverflow",
|
||||
"title": "restful"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"data": {
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
{
|
||||
"request": {
|
||||
"api_url":"http://api.stackexchange.com/2.2/search/advanced?order=desc&sort=relevance&site=stackoverflow&title=Zulip"
|
||||
"api_url":"http://api.stackexchange.com/2.2/search/advanced",
|
||||
"params": {
|
||||
"order": "desc",
|
||||
"sort": "relevance",
|
||||
"site": "stackoverflow",
|
||||
"title": "Zulip"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"data": {
|
||||
|
|
|
@ -45,11 +45,15 @@ class StackOverflowHandler(object):
|
|||
if query == '' or query == 'help':
|
||||
return help_text
|
||||
|
||||
query_stack_link = ('http://api.stackexchange.com/2.2/search/advanced?'
|
||||
'order=desc&sort=relevance&site=stackoverflow&title=%s'
|
||||
% (urllib.parse.quote(query),))
|
||||
query_stack_url = 'http://api.stackexchange.com/2.2/search/advanced'
|
||||
query_stack_params = dict(
|
||||
order='desc',
|
||||
sort='relevance',
|
||||
site='stackoverflow',
|
||||
title=query
|
||||
)
|
||||
try:
|
||||
data = requests.get(query_stack_link)
|
||||
data = requests.get(query_stack_url, params=query_stack_params)
|
||||
|
||||
except requests.exceptions.RequestException:
|
||||
logging.error('broken link')
|
||||
|
|
Loading…
Reference in a new issue