V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
hiddenstrawberry
V2EX  ›  Python

美团(猫眼)电影票价/信息爬虫

  •  
  •   hiddenstrawberry · 2017-08-10 16:15:24 +08:00 · 1910 次点击
    这是一个创建于 2442 天前的主题,其中的信息可能已经有所发展或是发生改变。

    美团电影爬虫 /美团电影价格图片混淆破解

    https://github.com/HiddenStrawberry/meituan-movie-price-crawler

    项目难点:


    让我们先来随便打开一个美团电影的页面

    此处输入图片的描述

    真是美滋滋啊,这个价格就写在上面!爬下来不就得了。

    定睛一看代码,我了个擦,这是个什么东西。

    此处输入图片的描述

    打开图片 URL,才明白过来,原来是一张大图一堆数字,用 CSS 定位的具体数字,美团你为了反爬真是煞费苦心啊……

    此处输入图片的描述


    Cracked


    requirement:

    bs4 requests Pillow/PIL

    需要独立安装 tesseract-ocr

    使用方法:

    1. 安装 tesseract-ocr
    2. 将 num.traineddata 复制粘贴到 tesseract 的 tessdata 目录中
    3. 修改 meituan_price_img.py 中的 TESSERACT_PATH 变量定位到 tesseract.exe (绝对路径)
    4. 打开 meituan.py ,Enjoy it !

    Example:

    print get_city_url('上海') #获取城市的地址
    print get_all_cinema('sh.meituan.com') #获取城市所有电影院信息
    print get_cinema_movie('http://sh.meituan.com/shop/58174') #获取指定电影院所有电影场次信息
    

    原理:

    你都看到 tesseract-ocr 了原理还用我废话嘛?机器学习了所有数字的样本(精准到 1px ),然后自动识别并输出咯。 PS:如果价格有手机专享价,会自动输出手机专享价!

    sunwei0325
        1
    sunwei0325  
       2017-08-12 13:17:18 +08:00
    验证码是不是也可以用这个库来搞事呢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5666 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 475ms · UTC 03:26 · PVG 11:26 · LAX 20:26 · JFK 23:26
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.