欢迎光临
我们一直在努力

python快手爬虫:解决粉丝数、 关注数等字体加密

 


想拿一下粉丝数 关注数 描述等
发现字体是加密的 elements是这样的

私信小编01即可获取大量Python学习资料

 

?
源代码里是这样的

 

?
找了找js 原来是用

?????

这些玩意 去??

?

 


这个ttf里一一对应 然后用 js + css画出来的
找到问题所在,就fuck掉它
把js扣出来?用execjs去执行?太LOW了
既然做python 那就用python去重写
首先用re去拿这个ttf的url (因为每次都变)

 

?
先给这玩意下载下来 把这个ttf文件扔fonteditor里 然后去
http://fontstore.baidu.com/static/editor/index.html
瞅瞅

 

?
这个时候就发现了东西

 

?

 

?
不就是这玩意吗,找到对应关系了 那就ok了
TTF文件没办法直接搞啊 ?怎么办
保存成xml !

 

?然后就成了这玩意 ok对应关系也有了 python也能搞了

去写一下 整逻辑就是
先去拿 ttf文件 url 请求url 保存 然后转xml
然后 拿加密前的特殊字符

# 就是这玩意
?????

 

然后去切割 对应 OK完事
对应关系的代码
根据看到的 id : 0啥也不说
从1~15 就是这些东西

 

?
上代码

# font_url 自己去动态拿 每次都变动
font_url = ''
font_res = requests.get(font_url)

  with open('font_size.ttf', 'wb+') as f:
      f.write(font_res.content)

  font = TTFont('font_size.ttf')
  font.saveXML('font_size.xml')
  soup = BeautifulSoup(open('font_size.xml'), 'lxml')
  try:
      fan = user_data_json['obfuseData']['fan'][40:-8].split(';&#x')
      fans = ''
      for f in fan:
          fans += kuaishou_un_font(soup, f)
  except:
      fans = ''

然后是拿TTF 文件然后转成xml

# TTF转XML
 font = TTFont('font_size.ttf')
  font.saveXML('font_size.xml')

和split后list去一一解密

# font_url 自己去动态拿 每次都变动
font_url = ''
font_res = requests.get(font_url)

  with open('font_size.ttf', 'wb+') as f:
      f.write(font_res.content)

  font = TTFont('font_size.ttf')
  font.saveXML('font_size.xml')
  soup = BeautifulSoup(open('font_size.xml'), 'lxml')
  try:
      fan = user_data_json['obfuseData']['fan'][40:-8].split(';&#x')
      fans = ''
      for f in fan:
          fans += kuaishou_un_font(soup, f)
  except:
      fans = ''
</code></pre><p>最后</p><p>?</p><div class="pgc-img"><img src="https://p6-tt.byteimg.com/origin/pgc-image/5b4ae0a0caff4686a6d2a7ba24e2f044?from=pc" img_width="559" img_height="225"  inline="0"><p class="pgc-img-caption"></p></div><p><br>OK~ 解码完成 全部代码没放 因为是根据需求写的 懒得改成大家都能用的了 主要是给个思路 思路有了就很简单 需要的找我</p></article><div class="content-action"><div class="meta-info"></div><div class="action-list"><div class="action-item favorite"><i class="bui-icon icon-favorite_line"></i><span>收藏</span></div><div class="action-item report"><i class="bui-icon icon-report"></i><span>举报</span></div></div></div></div><div class="media-info-wrapper"><div class="media-info"><div class="user-info"><a class="user-avatar" target="_blank" rel="noopener noreferrer" href="/c/user/token/MS4wLjABAAAAdUOhQfQSDIsysxcmTaXI3pwpO_oCTkUhdRaSmYP-uQDIgQcZ4qBt2GcZMS_LrCeB/"><img src="https://p6-tt-ipv6.byteimg.com/large/pgc-image/a8ab1c534959484fba067fe939bf0374" /></a><div class="user-name"><a class="name" target="_blank" rel="noopener noreferrer" href="/c/user/token/MS4wLjABAAAAdUOhQfQSDIsysxcmTaXI3pwpO_oCTkUhdRaSmYP-uQDIgQcZ4qBt2GcZMS_LrCeB/">青灯教育Python学院</a><div class="user-subscribe-wrapper"><i class="bui-icon icon-add_small"></i><span>关注</span></div></div></div><svg aria-labelledby="author-related-list-loading-aria" role="img" viewBox="0 0 245 125"><title id="author-related-list-loading-aria">Loading...</title><rect role="presentation" x="0" y="0" width="100%" height="100%" clip-path="url(#author-related-list-loading-diff)" style="fill:url(#author-related-list-loading-animated-diff)"></rect><defs role="presentation"><clipPath id="author-related-list-loading-diff"><circle cx="10" cy="20" r="5"></circle><rect x="25" y="15" rx="5" ry="5" width="220" height="10"></rect><circle cx="10" cy="50" r="5"></circle><rect x="25" y="45" rx="5" ry="5" width="220" height="10"></rect><circle cx="10" cy="80" r="5"></circle><rect x="25" y="75" rx="5" ry="5" width="220" height="10"></rect><circle cx="10" cy="110" r="5"></circle><rect x="25" y="105" rx="5" ry="5" width="220" height="10"></rect><circle cx="10" cy="140" r="5"></circle><rect x="25" y="135" rx="5" ry="5" width="220" height="10"></rect></clipPath><linearGradient id="author-related-list-loading-animated-diff"><stop offset="0%" stop-color="#f5f6f7" stop-opacity="1"></stop><stop offset="50%" stop-color="#eee" stop-opacity="1"></stop><stop offset="100%" stop-color="#f5f6f7" stop-opacity="1"></stop></linearGradient></defs></svg></div></div></div><div class="footer-feed-wrapper"><div><div>?</div></div></div></div><div class="toolbar"><div class="download shadow"><img src="https://sf3-dycdn-tos.pstatp.com/obj/eden-cn/pipieh7nupabozups/toutiao_web_pc/download.png" /><p>扫码下载今日头条</p></div><ul class="tool-container shadow"><li class="tool-item"><a href="//www.toutiao.com"><img class="icon" src="https://sf3-dycdn-tos.pstatp.com/obj/eden-cn/pipieh7nupabozups/toutiao_web_pc/homeicon.jpg" /></a></li><li class="tool-item"><img class="icon" src="https://sf3-dycdn-tos.pstatp.com/obj/eden-cn/pipieh7nupabozups/toutiao_web_pc/feedbackicon.jpg" /></li></ul></div></div></div><script type="text/javascript" src="//sf3-scmcdn-tos.pstatp.com/obj/goofy/toutiao/toutiao_web_pc/common/sylPage.d5c87e36.js"></script><script type="text/javascript" src="//sf3-scmcdn-tos.pstatp.com/obj/goofy/toutiao/toutiao_web_pc/common/vendor.33aa82a4.js"></script><script type="text/javascript" src="//sf3-scmcdn-tos.pstatp.com/obj/goofy/toutiao/toutiao_web_pc/pages/detail/index.99315a15.js"></script></body></html>
 收藏 (0) 打赏

您可以选择一种方式赞助本站

支付宝扫一扫赞助

微信钱包扫描赞助

未经允许不得转载:英协网 » python快手爬虫:解决粉丝数、 关注数等字体加密

分享到: 生成海报
avatar

热门文章

  • 评论 抢沙发

    • QQ号
    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址

    登录

    忘记密码 ?

    切换登录

    注册

    我们将发送一封验证邮件至你的邮箱, 请正确填写以完成账号注册和激活