从多个联机图书源查找图书下载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第三方库


热门话题
IntelliJ IDEA Java代码样式:注释和枚举之间的空间   java车辆路径问题或工具教程未在eclipse上运行   从HTML表单发布时,java非英语UTF 8字符会发生变化   使用MultiResourceItemReader时,java Spring批处理在CustomLineMapper中获取文件名   java配置JAXB解组器来处理同时具有acessor方法和字段的类   java在JpaRepository findAll()方法中返回对象的浅拷贝   java如何对docx文件进行碎片整理,以便与ApachePOI3.8一起使用?   java如何将一维数组分解成行?   java为什么这个图形对象不是绘画?(我做错了什么?)   如何在Java代码中将Java函数应用于Scala选项   使用IntelliJ REST客户端测试Spring MVC POST导致415   weka java代码kmeans群集   java中为什么Sin(30)=0.98803116240928618   java创建Android警报通知   数组可能是Java For循环问题