Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSM HTTP Error 403: Forbidden #5

Open
pat1 opened this issue Apr 13, 2016 · 0 comments
Open

OSM HTTP Error 403: Forbidden #5

pat1 opened this issue Apr 13, 2016 · 0 comments

Comments

@pat1
Copy link

pat1 commented Apr 13, 2016

According to:
http://wiki.openstreetmap.org/wiki/Nominatim_usage_policy#Requirements
we need to set HTTP Referer or we get urllib2.HTTPError: HTTP Error 403: Forbidden

req.add_header('Referer',YOUR SITE)
solve the problem but we have to set it in def init(self, base_url=None)

    def request(self, url):
        """                                                                                                                                                           
        Send a http request to the given *url*, try to decode                                                                                                         
        the reply assuming it's JSON in UTF-8, and return the result                                                                                                  

        :returns: Decoded result, or None in case of an error                                                                                                         
        :rtype: mixed                                                                                                                                                 
        """
        self.logger.debug('url:\n' + url)
        try:
            req = Request(url)
            req.add_header('Referer', 'http://rmap.cc')
            response = urlopen(req)
            return json.loads(response.read().decode('utf-8'))
        except URLError:
        self.logger.info('Server connection problem')
        except Exception:
            self.logger.info('Server format problem')
pat1 pushed a commit to r-map/nominatim that referenced this issue Apr 13, 2016
pat1 pushed a commit to r-map/rmap that referenced this issue Apr 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant