예제 #1
0
파일: run.py 프로젝트: od2016/opendata
        result.status = res.status_code
        #result.type = data.name
        if res.status_code == 200:
            try:
                result.type = Downloader.getFileNameNExtension(res)
                #result.type = Checker.checkExtension(file_name, data)
            except NotFileException, e:
                print e
                try:
                    result.type = Downloader.getFileExtension(res)
                except NoExceptionFound, e:
                    print e
                    result.type = Downloader.guessExtension(res)
                #result.type = Checker.checkType(res.read(), data)
    except HTTPError, e:
        result.status = -1
    except RequestException, e:
        result.status = -1
    except timeout, e:
        result.status = 0
    except Exception, e:
        print e
        result.status = -2

    count += 1
    print "(" + str(count) + "/" + str(size) + ") " + result.title.encode('utf-8') + "處理完成..."
    result_list.append(result)


ExcelCreater.exportExcel(result_list, 'Result.xlsx')
예제 #2
0
                    result.type = Downloader.getFileExtension(res)
                except NoExceptionFound, e:
                    print e
                    result.type = Downloader.guessExtension(res)
            # save file
            url = v.field_resource_url_g_url
            file_name = "file/" + str(v.nid) + "_" + v.title + "" + url[len(url)-4:]
            with open(file_name, "wb") as code:
                code.write(res.content)
            #
    except HTTPError, e:
        result.status = -1
        result.message = str(e.message).decode('utf-8')
    except RequestException, e:
        print e.message
        result.message = str(e.message).decode('utf-8')
        result.status = -1
    except timeout, e:
        result.status = 0
    except Exception, e:
        print e
        result.message = str(e.message).decode('utf-8')
        result.status = -2

    count += 1
    print "(" + str(count) + "/" + str(size) + ") " + v.title.encode('utf-8') + "處理完成..."
    results.append(result)


ExcelCreater.exportExcel(results, 'Result_save.xlsx')
예제 #3
0
            if res.status_code == 200:
                try:
                    v.type = Downloader.getFileNameNExtension(res)
                except NotFileException, e:
                    print e
                    try:
                        v.type = Downloader.getFileExtension(res)
                    except NoExceptionFound, e:
                        print e
                        v.type = Downloader.guessExtension(res)
        except HTTPError, e:
            v.status = -1
            v.message = str(e.message).decode('utf-8')
        except RequestException, e:
            print e.message
            v.message = str(e.message).decode('utf-8')
            v.status = -1
        except timeout, e:
            v.status = 0
        except Exception, e:
            print e
            v.message = str(e.message).decode('utf-8')
            v.status = -2

        count += 1
        print "(" + str(count) + "/" + str(size) + ") " + v.title.encode('utf-8') + "處理完成..."
        result.append(v)


ExcelCreater.exportExcel(result, 'Result_d.xlsx')