面向BBFC的API服务、库和解析器

bbfcapi的Python项目详细描述


BBFC API

PyPIPyPI - Python VersionPyPI - LicenseLibraries.io dependency status for GitHub repo

BBFC的Web API和Python库。在

公共REST API

Mozilla HTTP Observatory GradeSecurity Headers

现在就试试:

$ curl "https://bbfcapi.fustra.co.uk?title=interstellar"{"title":"Interstellar","ageRating":"12"}

使用Python客户端:

^{pr2}$
>>>frombbfcapi.api_syncimportbest_match>>>best_match("interstellar",2014)Film(title='INTERSTELLAR',age_rating=<AgeRating.AGE_12:'12'>)

工程概况

项目分为:

  • “我想自己托管上面演示的restapi”
    • BBFCAPI-Python REST Web API
    • pip install bbfcapi[app]
  • “我想要一个Python库来与上面演示的restapi对话”
    • 用于BBFCAPI的Python客户端
    • pip install bbfcapi[api_async](异步变量)
    • pip install bbfcapi[api_sync](同步变量)
  • “我想要一个Python库与BBFC网站对话”
    • BBFC网站的Python库
    • pip install bbfcapi[lib_async](异步变体)
    • pip install bbfcapi[lib_sync](同步变量)
  • “我想从BBFC下载原始HTML网页”
    • 用于BBFC网站的Python网络客户端
    • pip install bbfcapi[client_async](异步变量)
    • pip install bbfcapi[client_sync](同步变量)
  • “我想解析从BBFC下载的网页”
    • 用于BBFC网页的Python HMTL解析器
    • pip install bbfcapi

同步版本使用requests库,而异步变体使用aiohttp。在

高级REST Web API

安装pip install bbfcapi[app]。在

要使用REST API查询BBFC,请首先运行web服务器:

$ uvicorn bbfcapi.app:app

然后,要使用Python库同步查询API:

frombbfcapi.api_syncimportbest_matchbest_match("interstellar",base_url="http://127.0.0.1:8000")

或者,要使用Python库异步查询API:

frombbfcapi.api_asyncimportbest_matchprint(awaitbest_match("interstellar",base_url="http://127.0.0.1:8000"))
importasynciofrombbfcapi.api_asyncimportbest_matchprint(asyncio.run(best_match("interstellar",base_url="http://127.0.0.1:8000")))

或者,要使用curl查询API:

$ curl "127.0.0.1:8000?title=interstellar"{"title":"Interstellar",age_rating":"12"}

或者,要从其他网页查询API:

asyncfunctioncall(){constresponse=awaitfetch('http://127.0.0.1:8000/?title=interstellar');constresponseJson=awaitresponse.json();console.log(JSON.stringify(responseJson));}call();

附加说明:

高级Python库

要使用库从BBFC同步获取结果,请执行以下操作:

frombbfcapi.lib_asyncimportbest_matchprint(best_match(title="interstellar"))

要使用库从BBFC异步获取结果,请执行以下操作:

frombbfcapi.lib_asyncimportbest_matchprint(awaitbest_match(title="interstellar"))
importasynciofrombbfcapi.lib_asyncimportbest_matchprint(asyncio.run(best_match(title="interstellar")))

低级BBFC网络客户端和解析器

要使用库从BBFC同步获取原始HTML页面:

$ pip install bbfcapi[client_sync]`
frombbfcapi.client_syncimportsearchprint(search(title="interstellar"))

要使用库从BBFC异步获取原始HTML页面,请执行以下操作:

$ pip install bbfcapi[client_async]`
frombbfcapi.client_asyncimportsearchprint(awaitsearch(title="interstellar"))
importasynciofrombbfcapi.client_asyncimportsearchprint(asyncio.run(search(title="interstellar")))

要使用库解析来自BBFC的GraphQL API的结果,请执行以下操作:

$ pip install bbfcapi[parser]`
frombbfcapiimportparserprint(parser.best_autocomplete_match({"BBFC":"...graphql json..."}))

发展

  1. poetry install -E all设置virtualenv(一次性)
  2. poetry run uvicorn bbfcapi.apiweb:app --reload运行web服务器
  3. make fixmake check和{}提交之前

还有一个make test-live,它将对运行实时集成测试 BBFC网站。在

贡献

欢迎拉取请求:)

发布

这个应用程序发布在PyPi上。在

  1. 确保您已经用诗歌配置了PyPi存储库(一次性)
  2. 运行make release以执行检查列表

要发布到测试存储库:

  1. 确保您已经用诗歌配置了测试PyPi存储库(一次性)
  2. poetry publish --build -r testpypi上载到测试存储库

变更日志

未发布

。。。在

v3.0.0-2020年11月8日

  • 重要提示:与BBFC新网站的兼容性有重大变化
  • 更新各种依赖项

v2.0.2-2020年3月22日

  • 修复另一个丢失的依赖项

v2.0.1-2020年3月22日

  • 修复缺少的依赖项

v2.0.0-2020年3月22日

  • 为BBFCAPI REST Web API添加Python客户端库
  • 在webapi中为JSON字段使用camelCasing
  • 重组整个程序包

v1.0.1-2020年1月19日

  • 修正分析12A年龄等级

v1.0.0-2020年1月19日

  • bbfcapi的首次发布

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java查询,该查询应返回特定相关实体的实体   java创建了两个可运行的JAR,它们使用相同的库而不需要两次   java swing应用程序如何设置面板中组件的高度(和宽度)   在fat jar中找不到java JasperReport文件错误   kotlin在java中如何称呼这个构造函数?   java为什么被零除是一个不可恢复的问题?   java为SUTime添加用于解析季度的自定义规则   java merge 2带所有元素的排序列表   从字符串StringUtils Java中提取数字   java ForLoops最大和最小数   java我可以为嵌入式tomcat 8定义始终保持活动状态的最小executer线程数吗?   java当metod返回ResponseEntry<Resource>抛出错误时,如何返回ModelandView?   java片段翻译和电话定位错误   javagwt:如何让regex(模式和匹配器)在客户端工作   java EAR文件和“WebSphere增强的EAR”之间有什么区别?