http flu season question python not sure why im getting this output












0















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?










share|improve this question

























  • 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


















0















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?










share|improve this question

























  • 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
















0












0








0








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?










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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





















  • 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














2 Answers
2






active

oldest

votes


















1














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"





share|improve this answer
























  • 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



















0














figured it out thanks i wasn't returning the total number initially






share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    1














    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"





    share|improve this answer
























    • 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
















    1














    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"





    share|improve this answer
























    • 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














    1












    1








    1







    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"





    share|improve this answer













    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"






    share|improve this answer












    share|improve this answer



    share|improve this answer










    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



















    • 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













    0














    figured it out thanks i wasn't returning the total number initially






    share|improve this answer




























      0














      figured it out thanks i wasn't returning the total number initially






      share|improve this answer


























        0












        0








        0







        figured it out thanks i wasn't returning the total number initially






        share|improve this answer













        figured it out thanks i wasn't returning the total number initially







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 27 '18 at 20:22









        codernoob3232codernoob3232

        146




        146






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Lallio

            Futebolista

            Jornalista