0

包含错误的部分代码:

select_link = db.GqlQuery("select * from PhishTank where url= :1",str(updated_url))
    in_database_phishtank = False
    for link in select_link:
        if str(updated_url) == str(link.url):
            in_database_phishtank = True
            # chk for 7 days period , update the link
            if (datetime.now()-link.timestamp) > timedelta(days = TIME_UPDATE):
                # query to the site and update the datastore
                url = "http://checkurl.phishtank.com/checkurl/"
                parameters = {"url": "%s" % updated_url,
                               "app_key": "74283d86612c6b89de0b186882446e069dd071f65e9711aa374e9cdbd2ba7ffe",
                              "format":"json"}
                data = urllib.urlencode(parameters)
                req = urllib.Request(url, data)
                try:
                    response = urllib2.urlopen(req)
                except urllib.error.URLError as e:
                    self.redirect('/error')
                json_post = response.read()
                data = json.loads(json_post)
4

1 回答 1

0

尝试这个:

urllib.request.Request(url, data)

请注意,在 Python 3.xurllib中被拆分为几个模块:urllib.requesturllib.parseurllib.error. 您可能导入错误。

于 2013-05-07T16:19:00.363 回答