http flu season question python not sure why im getting this output
Write a function named "flu_season" that doesn't take any parameters. Study the documentation for this API that tracks tweets containing flu symptoms (http://www.flutrack.org). Send a request to the url "https://fury.cse.buffalo.edu/ps-api/flutrack/" which will use the same format as the linked API (ex. instead of connecting to http://api.flutrack.org/ use https://fury.cse.buffalo.edu/ps-api/flutrack/, but use the same query string as you would with the linked API). Return the total number of tweets containing flu symptoms over the past 2 days
Note: We are using a local API to avoid limits on the free API and for grading consistent grading. Feel free to explore the linked API while testing
import urllib.request
def flu_season():
url = "https://fury.cse.buffalo.edu/ps-api/flutrack/?a=True&time=2"
response = urllib.request.urlopen(url)
url1 = response.read().decode()
return url1
error on input : error: Traceback (most recent call last):
File "sandbox/python/run_function.py", line 115, in
call_all(submission_file_path, function_name, all_inputs_filename, results_filename, written_filename, sql_output_filename)
File "sandbox/python/run_function.py", line 102, in call_all
print(all_results)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 103-109: ordinal not in range(128)
how can i fix this?
python http
add a comment |
Write a function named "flu_season" that doesn't take any parameters. Study the documentation for this API that tracks tweets containing flu symptoms (http://www.flutrack.org). Send a request to the url "https://fury.cse.buffalo.edu/ps-api/flutrack/" which will use the same format as the linked API (ex. instead of connecting to http://api.flutrack.org/ use https://fury.cse.buffalo.edu/ps-api/flutrack/, but use the same query string as you would with the linked API). Return the total number of tweets containing flu symptoms over the past 2 days
Note: We are using a local API to avoid limits on the free API and for grading consistent grading. Feel free to explore the linked API while testing
import urllib.request
def flu_season():
url = "https://fury.cse.buffalo.edu/ps-api/flutrack/?a=True&time=2"
response = urllib.request.urlopen(url)
url1 = response.read().decode()
return url1
error on input : error: Traceback (most recent call last):
File "sandbox/python/run_function.py", line 115, in
call_all(submission_file_path, function_name, all_inputs_filename, results_filename, written_filename, sql_output_filename)
File "sandbox/python/run_function.py", line 102, in call_all
print(all_results)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 103-109: ordinal not in range(128)
how can i fix this?
python http
Did you look at what your url looks after glueing it? You are missing & in between the params
– Patrick Artner
Nov 27 '18 at 19:41
add a comment |
Write a function named "flu_season" that doesn't take any parameters. Study the documentation for this API that tracks tweets containing flu symptoms (http://www.flutrack.org). Send a request to the url "https://fury.cse.buffalo.edu/ps-api/flutrack/" which will use the same format as the linked API (ex. instead of connecting to http://api.flutrack.org/ use https://fury.cse.buffalo.edu/ps-api/flutrack/, but use the same query string as you would with the linked API). Return the total number of tweets containing flu symptoms over the past 2 days
Note: We are using a local API to avoid limits on the free API and for grading consistent grading. Feel free to explore the linked API while testing
import urllib.request
def flu_season():
url = "https://fury.cse.buffalo.edu/ps-api/flutrack/?a=True&time=2"
response = urllib.request.urlopen(url)
url1 = response.read().decode()
return url1
error on input : error: Traceback (most recent call last):
File "sandbox/python/run_function.py", line 115, in
call_all(submission_file_path, function_name, all_inputs_filename, results_filename, written_filename, sql_output_filename)
File "sandbox/python/run_function.py", line 102, in call_all
print(all_results)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 103-109: ordinal not in range(128)
how can i fix this?
python http
Write a function named "flu_season" that doesn't take any parameters. Study the documentation for this API that tracks tweets containing flu symptoms (http://www.flutrack.org). Send a request to the url "https://fury.cse.buffalo.edu/ps-api/flutrack/" which will use the same format as the linked API (ex. instead of connecting to http://api.flutrack.org/ use https://fury.cse.buffalo.edu/ps-api/flutrack/, but use the same query string as you would with the linked API). Return the total number of tweets containing flu symptoms over the past 2 days
Note: We are using a local API to avoid limits on the free API and for grading consistent grading. Feel free to explore the linked API while testing
import urllib.request
def flu_season():
url = "https://fury.cse.buffalo.edu/ps-api/flutrack/?a=True&time=2"
response = urllib.request.urlopen(url)
url1 = response.read().decode()
return url1
error on input : error: Traceback (most recent call last):
File "sandbox/python/run_function.py", line 115, in
call_all(submission_file_path, function_name, all_inputs_filename, results_filename, written_filename, sql_output_filename)
File "sandbox/python/run_function.py", line 102, in call_all
print(all_results)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 103-109: ordinal not in range(128)
how can i fix this?
python http
python http
edited Nov 27 '18 at 19:48
codernoob3232
asked Nov 27 '18 at 19:38
codernoob3232codernoob3232
146
146
Did you look at what your url looks after glueing it? You are missing & in between the params
– Patrick Artner
Nov 27 '18 at 19:41
add a comment |
Did you look at what your url looks after glueing it? You are missing & in between the params
– Patrick Artner
Nov 27 '18 at 19:41
Did you look at what your url looks after glueing it? You are missing & in between the params
– Patrick Artner
Nov 27 '18 at 19:41
Did you look at what your url looks after glueing it? You are missing & in between the params
– Patrick Artner
Nov 27 '18 at 19:41
add a comment |
2 Answers
2
active
oldest
votes
url = "https://fury.cse.buffalo.edu/ps-api/flutrack/?" + "a = True" + "time = 2"
This will cause url to have the value https://fury.cse.buffalo.edu/ps-api/flutrack/?a = Truetime = 2. The part after the question mark does not look like a valid query string to me. Query strings typically do not have spaces, and the key-value pairs are typically separated with ampersands.
Perhaps instead you could do:
url = "https://fury.cse.buffalo.edu/ps-api/flutrack/?a=True&time=2"
ah okay, so i did that and a new traceback error came up, as shown in my edited question, not sure if im missing a line of code or not
– codernoob3232
Nov 27 '18 at 19:50
add a comment |
figured it out thanks i wasn't returning the total number initially
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53506929%2fhttp-flu-season-question-python-not-sure-why-im-getting-this-output%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
url = "https://fury.cse.buffalo.edu/ps-api/flutrack/?" + "a = True" + "time = 2"
This will cause url to have the value https://fury.cse.buffalo.edu/ps-api/flutrack/?a = Truetime = 2. The part after the question mark does not look like a valid query string to me. Query strings typically do not have spaces, and the key-value pairs are typically separated with ampersands.
Perhaps instead you could do:
url = "https://fury.cse.buffalo.edu/ps-api/flutrack/?a=True&time=2"
ah okay, so i did that and a new traceback error came up, as shown in my edited question, not sure if im missing a line of code or not
– codernoob3232
Nov 27 '18 at 19:50
add a comment |
url = "https://fury.cse.buffalo.edu/ps-api/flutrack/?" + "a = True" + "time = 2"
This will cause url to have the value https://fury.cse.buffalo.edu/ps-api/flutrack/?a = Truetime = 2. The part after the question mark does not look like a valid query string to me. Query strings typically do not have spaces, and the key-value pairs are typically separated with ampersands.
Perhaps instead you could do:
url = "https://fury.cse.buffalo.edu/ps-api/flutrack/?a=True&time=2"
ah okay, so i did that and a new traceback error came up, as shown in my edited question, not sure if im missing a line of code or not
– codernoob3232
Nov 27 '18 at 19:50
add a comment |
url = "https://fury.cse.buffalo.edu/ps-api/flutrack/?" + "a = True" + "time = 2"
This will cause url to have the value https://fury.cse.buffalo.edu/ps-api/flutrack/?a = Truetime = 2. The part after the question mark does not look like a valid query string to me. Query strings typically do not have spaces, and the key-value pairs are typically separated with ampersands.
Perhaps instead you could do:
url = "https://fury.cse.buffalo.edu/ps-api/flutrack/?a=True&time=2"
url = "https://fury.cse.buffalo.edu/ps-api/flutrack/?" + "a = True" + "time = 2"
This will cause url to have the value https://fury.cse.buffalo.edu/ps-api/flutrack/?a = Truetime = 2. The part after the question mark does not look like a valid query string to me. Query strings typically do not have spaces, and the key-value pairs are typically separated with ampersands.
Perhaps instead you could do:
url = "https://fury.cse.buffalo.edu/ps-api/flutrack/?a=True&time=2"
answered Nov 27 '18 at 19:41
KevinKevin
59.2k1169113
59.2k1169113
ah okay, so i did that and a new traceback error came up, as shown in my edited question, not sure if im missing a line of code or not
– codernoob3232
Nov 27 '18 at 19:50
add a comment |
ah okay, so i did that and a new traceback error came up, as shown in my edited question, not sure if im missing a line of code or not
– codernoob3232
Nov 27 '18 at 19:50
ah okay, so i did that and a new traceback error came up, as shown in my edited question, not sure if im missing a line of code or not
– codernoob3232
Nov 27 '18 at 19:50
ah okay, so i did that and a new traceback error came up, as shown in my edited question, not sure if im missing a line of code or not
– codernoob3232
Nov 27 '18 at 19:50
add a comment |
figured it out thanks i wasn't returning the total number initially
add a comment |
figured it out thanks i wasn't returning the total number initially
add a comment |
figured it out thanks i wasn't returning the total number initially
figured it out thanks i wasn't returning the total number initially
answered Nov 27 '18 at 20:22
codernoob3232codernoob3232
146
146
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53506929%2fhttp-flu-season-question-python-not-sure-why-im-getting-this-output%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you look at what your url looks after glueing it? You are missing & in between the params
– Patrick Artner
Nov 27 '18 at 19:41