从多个联机图书源查找图书下载URL

pybooks的Python项目详细描述


安装

$ pip install pybooks

用法

简单用法

from pybooks.pbook import Pbooks 

pbook = Pbooks( author='jerome',
                title='elements of statistic',
                weights=(9, 1)) 
         

pbook.main()

参数weights用于计算找到的所有项和最终选择的url的准确性。例如,weights(9, 1)将比title对作者准确性更重要,因此结果更有可能使author的名称与输入更相似。默认权重为(1, 1)

可选参数有show_result: Print the result at the end or notthreshold: Only print result with accuracy higher than thresholdlog: Show process while running or not等。在代码文档中可以找到更多参数。

可以通过编辑文件PyBoox/SuthCE.jSON修改和添加其他源,并按照文件中的现有格式。

sources.json格式,规则

示例: Library Genesis with elements of statistics as search term

我们在url中只需要以下组件:request: ?req=...delimiter: + (elements+of+statistics)pagination: page=...term_concatenation: & (req=...&page=...)

INSIDE SOURCES.JSON

URL: main url without search terms
URL_RULES: dictionary contains keys and values as search rules.
HTML_RULES: Contains nested dictionary represent necessary components to conduct searches such as tags, attributes for titles, authors, rows and page body
.POSITION: The position of the that element in the row if there are other similar elements with similar tag and attributes, leave as null if it is unique
.TAG: The tag of the desired element
.ATTRIBUTE: Attributes of the tag, for exanple: {"class": "id", "...": "..", ...}. Leave the value of a key as true if an attribute has no value

命令行用法

可以直接从命令行使用包 示例:搜索一本书名为“统计学习要素”和作者为“Jerome Friedman”的书 您可以将pbook.exe添加到环境变量中,并通过此命令从命令行使用它,%PATH%作为指向pybooks目录(文件夹)的路径,通常可以在\Python{version}\Lib\pybooks中找到。

setx PATH "%PATH%
pbook -a "jerome friedman" -t "elements of statistical learning"
OPTIONAL ARGUMENTS
-h, --help            show this help message and exit
  -a AUTHOR, --author AUTHOR
                        Author of the book you want to find
  -t TITLE, --title TITLE
                        Title of the book you want to find
  -w WEIGHTS, --weights WEIGHTS
                        Assign author and title weight to the final accuracy
                        calculation
  -th THRESHOLD, --threshold THRESHOLD
                        Only get results above the threshold amount
  -l LOG, --log LOG     Print out the process
  -s SHOW, --show SHOW  Show result at the end of running
  -br BREAK_AT, --break-at BREAK_AT
                        Stop when encounter a book with accuracy higher than
                        or equal to this number
  -m METHOD, --method METHOD
                        Choose a book evaluation method

许可证

麻省理工学院

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

推荐PyPI第三方库


热门话题
java无法使用JSF访问托管bean方法   java是制作具有多值类型的HashMap的正确方法   javafx中TicTacToe的java更新UI   windows Java文件。getCanonicalFile()无法处理冒号“:”   java在一个布局屏幕中创建多个(26)按钮   java Android Studio:Gradle构建完成,有251个错误   我们如何在Java上为callfireapiclient编写单元/集成测试?   java无法将1715UTC转换为本地/gmt类型   具有已定义的数字序列的JAVA循环   Java程序正在netbeans中编译,但未在CMD中编译,包不存在   java Android构造函数和onCreate()之间有什么区别?   java配置弹性搜索结果评分   java LibGDX纹理是否可绘制?   java如何在Android中设置应用程序默认打开pdf   java是否有一种创造性的方法将多个参数传递给contentEquals()方法?   java在Android上存储Ed25519私钥