Pinterest API - returning 403 on EC2 Instance

你。 提交于 2019-12-02 11:01:56

Not an answer, but hopefully this will save someone else an hour trying this approach: Pinterest, unsurprisingly, appears to also be blocking requests from tor exit routers.

I had the same problem with the same endpoint and narrowed it down to EC2 + Pinterest as well. I attempted to circumvent it by routing the request through tor.

class PinterestService(Service):
    service_url = "http://api.pinterest.com/v1/urls/count.json?callback="
    url_param = 'url'

    def get_response(self, url, **params):
        params[self.url_param] = url

        # privoxy listens by default on port 8118
        # on the ec2 privoxy is configured to forward
        # socks5 through tor like so:
        # http://fixitts.com/2012/05/26/installing-tor-and-privoxy-on-ubuntu-server-or-any-other-linux-machine/

        http_proxy  = "socks5://127.0.0.1:8118"

        proxyDict = { 
          "http"  : http_proxy
        }

        return requests.get(self.service_url, params=params, proxies=proxyDict)

I have cycled through numerous exit routers and the response is consistently { "status": 403, "message": "Forbidden" }

For a solve I am going to go through a private http proxy server

This question was filed a few years ago, and the current answer I believe is out of date. EC2 now runs the above script with a successful response without the need for a proxy. I came across this question while investigating my own similar issue with Google App Engine.

Pinterest is probably blocking requests from IP blocks owned by Amazon, resulting in the 403: Forbidden error. Pinterest doesn't have official support for their API, so (my supposition is) that they are blocking the largest possible sources of commercial usage of their API. You can test this by using an instance from a non-AWS provider.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!