搜索矿山目录

csmdirsearch的Python项目详细描述


Mines DirSearch网站允许搜索拥有 标题系统中列出的目录信息。这是一条方便的Python 与该网站的接口。

Author:Jack Rosenthal
Requires:Python 3.4 or greater, Beautiful Soup 4.4.0 or greater, Requests
License:MIT
Contributing:See ^{tt1}$

安装

克隆the repository并安装:

$ pip install . --user

或者从pypi安装:

$ pip install csmdirsearch --user

来自python的用法

使用search(query)通过用户名(部分)搜索用户,或 (部分)全名。search是生成唯一 Person对象。此对象的典型属性包括namebusiness_emailmajorclassificationdepartment;但是, 仅保证了^ {Tt5} $属性存在。

每个Person对象也有一些属性:

^{tt12}$:Based on the ^{tt6}$ (and potentially more information in the future), a “best guess” for the username of the user, otherwise ^{tt14}$.
^{tt15}$:An automatic, brief description of the person, for example: ^{tt16}$.

每个人的name也是一个特殊的Name类型,包含 firstlastnick属性您可以将名称转换为 使用strfname函数的字符串,或使用str(person.name)作为 “合理违约”:

>>> name = Name("Rosenthal, Jack (NickName)")
>>> name.strfname("{first} {last}")
'Jack Rosenthal'
>>> str(name)
'Jack (NickName) Rosenthal'

strfname中还可以使用方便的属性:

^{tt25}$:Short for “preferred first”. This will be set to ^{tt21}$ if there is a nick name, ^{tt19}$ otherwise.
^{tt28}$:Short for “nick, wrapped in parens, if there is one”. This will be set to ^{tt29}$ if there’s a nick name, ^{tt30}$ otherwise.

示例:

>>> name = Name("Rosenthal, Jack (NickName)")
>>> name.strfname("{pfirst} {last}")
'NickName Rosenthal'
>>> name.strfname("{first}{nickp} {last}")
'Jack (NickName) Rosenthal'

下面是一个示例:

import csmdirsearch
for person in csmdirsearch.search("Jack Rosenthal"):
    print(person.name, person.desc)

如果您希望将搜索限制为,只需一个部分用户名(没有实名 使用search_by_partial生成器,而不是search

最后,如果您希望将搜索限制为,只需部分全名(大多数 使用search_by_name生成器而不是search。这个 生成器还具有将搜索限制为特定分类或 部门。阅读源代码了解更多详细信息

从命令行使用

这很简单:

$ dirsearch "Jack Rosenthal"
Jack Rosenthal
Undergraduate Student
Business Email: ...

如果要使用search_by_namesearch_by_partial函数 限制输入的范围,使用--input=name--input=partial 分别:

$ dirsearch --input=partial "jrosent"
Jack Rosenthal
...

来自mutt的用法

添加到您的.muttrc

set query_command = "dirsearch --format=mutt %s"

然后按Q使用搜索进行撰写,或在写入名称或 地址。

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

推荐PyPI第三方库


热门话题
Java Double。将长位加倍到C#位转换器。ToDouble   java如何使用正则表达式从固定的Y位数中提取最后的X位数?   java如何显示ChatMessage类列表中的字符串消息属性?   java从JSON或XML提要导入数据,并在Android中创建列表   在整数之间使用按位AND运算符的java好处?   java从Android中的Bean类获取空值?   java会话id对另一台服务器意味着什么?   java未选择案例时开关的工作方式   java组织。openqa。硒。SessionNotCreatedException:无法创建新的远程会话。在emulator中初始化安卓驱动程序时   JavaSWT父和子对话框通信   java请确保java_HOME指向JDK而不是JRE   java用户即使在成功登录后也是匿名的   java控制器单元测试无法自动连接所需的bean   Java小程序类文件