semvec/pypi-packages huggingface dataset:
maoyan-font 2018.12.1
将猫眼电影网页中票房、评分等数据的乱码转化成正常数字。

## maoyan-font

### 简介

将猫眼电影网页中票房、评分等数据的乱码转化成正常数字。

### 安装

```bash
pip install maoyan-font
```
或者

```bash
git clone https://github.com/digglife/maoyan-font
cd maoyan-font
python setup.py install
```

### 用法

```python

from maoyan_font import MaoyanFontParser

parser = MaoyanFontParser()
font = parser.load('http://vfile.meituan.net/colorstone/294024cb386679d8e940022d5e3b6a162088.woff')
font.normalize('\uf8bc.\ueb54')
# '9.1'

```

本模块附带了一个命令行工具 `mybox`, 用于展示模块的用法。

```bash

$ mybox https://maoyan.com/films/249342
{'name': '海王', 'box': '468万'}

$ mybox -h

usage: mybox [-h] url

get box office info via url

positional arguments:
  url         movie url to parse

optional arguments:
  -h, --help  show this help message and exit

```


### 原理

猫眼为了保护重要数据，对评分和票房数据采用了 网络字体反爬机制。概括而言，就是 HTML 中的返回无对应字符的 Unicode 代码（[Unicode 私人使用区](https://zh.wikipedia.org/wiki/%E7%A7%81%E4%BA%BA%E4%BD%BF%E7%94%A8%E5%8C%BA)），
然后使用网络字体在浏览器中渲染出代码对应的数字。

每次请求电影页面，下载的 woff 都不同，每个 woff 中的 Unicode 代码对应的数字也都不同。比如，woff A 中，`\uE851` 对应的是 数字 0， woff B 中 数字0 对应的代码可能是 `\uE748`，没有规律可言。
但是字体的字形数据 (Glyphs) 是不变的，我们只要获取猫眼的任一 woff，找出字形和数字的对应关系，保存为字典，然后每次抓取时，解析出新字体中的字形，在字典中查询即可获取真正的数字。

### 许可证

[MIT](LICENSE)
ochelper 0.0.6
ochelper for objective-c
Keywords: objective-c code proc

# A sample Python project

A sample project that exists as an aid to the [Python Packaging User
Guide][packaging guide]'s [Tutorial on Packaging and Distributing
Projects][distribution tutorial].

This project does not aim to cover best practices for Python project
development as a whole. For example, it does not provide guidance or tool
recommendations for version control, documentation, or testing.

[The source for this project is available here][src].

Most of the configuration for a Python project is done in the `setup.py` file,
an example of which is included in this project. You should edit this file
accordingly to adapt this sample project to your needs.

----

This is the README file for the project.

The file should use UTF-8 encoding and can be written using
[reStructuredText][rst] or [markdown][md use] with the appropriate [key set][md
use]. It will be used to generate the project webpage on PyPI and will be
displayed as the project homepage on common code-hosting services, and should be
written for that purpose.

Typical contents for this file would include an overview of the project, basic
usage examples, etc. Generally, including the project changelog in here is not a
good idea, although a simple “What's New” section for the most recent version
may be appropriate.

[packaging guide]: https://packaging.python.org
[distribution tutorial]: https://packaging.python.org/en/latest/distributing.html
[src]: https://github.com/pypa/sampleproject
[rst]: http://docutils.sourceforge.net/rst.html
[md]: https://tools.ietf.org/html/rfc7764#section-3.5 "CommonMark variant"
[md use]: https://packaging.python.org/specifications/core-metadata/#description-content-type-optional