用于匹配url的python库。

urlmatch的Python项目详细描述


使用urlmatch验证url是否符合某些模式。这个 库和匹配模式主要基于Google Chrome Extension match patterns

用法

fromurlmatchimporturlmatchmatch_pattern='http://*.example.com/*'urlmatch(match_pattern,'http://subdomain.example.com/')# Trueurlmatch(match_pattern,'http://sub.subdomain.example.com/')# Trueurlmatch(match_pattern,'https://example.com/')# Falseurlmatch(match_pattern,'http://bad.com/')# False

选项

有几个选项会影响匹配模式的工作方式。

  • path_required(默认值为true)-abool,它指示 匹配模式是否必须具有路径
  • fuzzy_scheme(默认值为false)-abool,它指示 方案是否应该“模糊地”匹配。如果这是真的,那么 任何有效的方案(*httphttps)都将同时匹配 httphttps
  • http_auth_allowed(默认值为true)-bool,它指示 是否应允许URL中包含HTTP身份验证的URL,或者 不

匹配模式语法

基本的匹配模式语法很简单:

<url-pattern> := <scheme>://<host><path>
<scheme> := '*' | 'http' | 'https'
<host> := '*' | '*.' <any char except '/' and '*'>+
<path> := '/' <any chars>

示例

  • http://*/*-匹配任何使用http方案的url
  • https://*/*-匹配任何使用https方案的url
  • http://*/test*-匹配任何使用http方案的url和 路径以test
  • 开头
  • *://test.com/*-匹配域的任何url test.com
  • http://*.test.com-匹配test.comtest.com
  • http://test.com/foo/bar.html-与准确的url匹配

错误

如果您发现问题,请在问题部分告诉我!

贡献

Rubinius贡献页面:

Writing code and participating should be fun, not an exercise in perseverance. Stringent commit polices, for whatever their other qualities may bring, also mean longer turnaround times.

提交修补程序,一旦被接受,您将获得对 储存库。请随意分叉存储库并发送一个请求, 一旦它被合并进来,你就会被添加进去。如果没有,请随意窃听 jessepollak关于它。

如何贡献

  • 克隆:git@github.com:jessepollak/urlmatch.git
  • 创建主题分支:git checkout -b awesome_feature
  • 提交(并为您编写的任何代码添加单元测试)。
  • 保持最新:^{TT25}$。
  • 运行测试:python setup.py test

一旦您准备好了:

  • 在github上派生项目
  • 将存储库添加为远程: git remote add your_remote your_repo
  • 向上推你的树枝:git push your_remote awesome_feature
  • 为主题分支创建拉取请求,请求审阅。

一旦被接受:

  • 如果您想访问核心存储库,请随时询问!那么你 可以更改原点以指向读写URL:
git remote set-url origin git@github.com:jessepollak/urlmatch.git

否则,你可以用自己的叉子继续砍下去。

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

推荐PyPI第三方库


热门话题
java Spring MVC 4.0 RequestMapping无值,基于methodname   java Samsung 10 plus不允许wifi p2p发现   春爪哇。伊奥。IOException:找不到文件   java JasperReport饼图示例   java我试图使用mockito注释来测试我的代码,但无法解决mockito异常   命令行界面Java:制作简单的交互式cli应用程序   java jdk1之间的区别是什么。7_9 9和jdk1。7_271   java重载一个被重写的、继承的方法   java LazyInitializationException春季启动   java Play Framework 2.2.1 3个表之间存在大量关系