Skip to main content

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使用。

参数解释:

返回值:

  1. rate: 猫眼评分
  2. rate_num: 猫眼评分人数
  3. money: 票房,元人民币为单位,如果是美元会按照 2021/10/26 日汇率进行计算。
  4. money_unit: 票房的单位,只有 3 种单位
    1. 万: 1e4,
    2. 亿: 1e8,
    3. 万美元: 63900

输入值:

  1. 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]
    
  2. rate_num_raw: 未经处理的评分人数,

  3. font_file: 每一个电影的详情页都会有一个新生成的字体,这个属性需要这个字体文件的io.BytesIO()的形式,建议通过网页上的详情把字体下载下来再传进来。

  4. money_raw: 未经处理的票房,

  5. money_unit: 票房单位。

测试

测试结果:

image-20211028213546725

输出: 2 extra bytes in post.stringData array,是TTFont库造成的,不会影响正常使用。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maoyan-font-recognize-0.1.3.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

maoyan_font_recognize-0.1.3-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

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

Hashes for maoyan-font-recognize-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ad2b72ef2e868ae3156010a89ff2933c5ba853a95585a310132f313432304aa5
MD5 1fde3fe495635fb18cf7d55eebc7cb0b
BLAKE2b-256 7e570c53eaee0e5965449f90a976f0ac89833e02f1f18702c3742082b8a907bf

See more details on using hashes here.

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

Hashes for maoyan_font_recognize-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b1f2e073cb1479c050112d5671858c70f93415760b4f3951bd89f45c65598226
MD5 47799ebbc2bcc1ef5454b6264544faff
BLAKE2b-256 6146d7facf03a452978a05d1a774f7c41047ad7fe9cf68fb6357081759c286f4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page