open url from pythonanywhere

前端 未结 3 1208
天命终不由人
天命终不由人 2020-11-28 16:02

This code works well on my local machine, but when I upload and run it on pythonanywhere.com it gives me this error.
My Code:

url = \"http://www.codefor         


        
相关标签:
3条回答
  • 2020-11-28 16:36

    I recently used urllib2 with a flask project on pythonanywhere using their free account to access an api at donorschoose.org

    This might be helpful,

    @app.route('/funding')
    def fundingByState():
        urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler({'http': 'proxy.server:3128'})))
        donors_choose_url = "http://api.donorschoose.org/common/json_feed.html?historical=true&APIKey=DONORSCHOOSE"
        response = urllib2.urlopen(donors_choose_url)
        json_response = json.load(response)
        return json.dumps(json_response)
    

    This does work.

    0 讨论(0)
  • 2020-11-28 16:53

    If you're using paid account but still get this error message try this pythonanywhere_forums

    To me, I have to delete the console then restart a new one.

    0 讨论(0)
  • 2020-11-28 16:55

    Free accounts on PythonAnywhere are restricted to a whitelist of sites, http/https only, and access goes via a proxy. There's more info here:

    PythonAnywhere wiki: "why do I get a 403 forbidden error when opening a url?"

    0 讨论(0)
提交回复
热议问题