A lib to recognize MaoYan font from the offical website.
Project description
猫眼字体识别
该 github repo 在于帮助xjtlu的同学们识别猫眼的扭曲字体。已经打包上传至 pypi ,可以使用 pip
直接安装。
猫眼字体的识别不出来的原理与解决思路在采茶上
使用方法:
import MaoYanFontRecognize
m = MaoYanFontRecognize.MaoYanFont()
rate, rate_num, money = m.translate(rate_raw, rate_num_raw, font_file, money_raw= -1, money_unit=1)
更细致的使用方式请看test。
请注意,每一个电影的详情页的字体都是猫眼特殊生成的。也就是说,每次刷新之后的字体文件都是不一样的。所以要把每一个详情页中的字体文件同时下载下来,当成参数font_file
使用。
参数解释:
返回值:
rate
: 猫眼评分rate_num
: 猫眼评分人数money
: 票房,元人民币为单位,如果是美元会按照 2021/10/26 日汇率进行计算。money_unit
: 票房的单位,只有 3 种单位- 万: 1e4,
- 亿: 1e8,
- 万美元: 63900
输入值:
-
rate_raw
: 未经处理的猫眼评分,从猫眼上直接爬下来的数据,放进bs4
之后的tag
里的contents
,下面代码是实例,以下的几个属性都差不多:spans = soup("span", class_="stonefont") rate_raw = spans[0].contents[0] rate_num_raw = spans[1].contents[0] money_raw = spans[2].contents[0]
-
rate_num_raw
: 未经处理的评分人数, -
font_file
: 每一个电影的详情页都会有一个新生成的字体,这个属性需要这个字体文件的io.BytesIO()
的形式,建议通过网页上的详情把字体下载下来再传进来。 -
money_raw
: 未经处理的票房, -
money_unit
: 票房单位。
测试
测试结果:
输出: 2 extra bytes in post.stringData array
,是TTFont库造成的,不会影响正常使用。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file maoyan-font-recognize-0.1.3.tar.gz
.
File metadata
- Download URL: maoyan-font-recognize-0.1.3.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.0.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad2b72ef2e868ae3156010a89ff2933c5ba853a95585a310132f313432304aa5 |
|
MD5 | 1fde3fe495635fb18cf7d55eebc7cb0b |
|
BLAKE2b-256 | 7e570c53eaee0e5965449f90a976f0ac89833e02f1f18702c3742082b8a907bf |
File details
Details for the file maoyan_font_recognize-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: maoyan_font_recognize-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.0.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1f2e073cb1479c050112d5671858c70f93415760b4f3951bd89f45c65598226 |
|
MD5 | 47799ebbc2bcc1ef5454b6264544faff |
|
BLAKE2b-256 | 6146d7facf03a452978a05d1a774f7c41047ad7fe9cf68fb6357081759c286f4 |