Giter Club home page Giter Club logo

taobao's Introduction

手淘H5页面商品信息爬虫test

破解淘宝js生成sign参数。

新增淘宝pyppeteer登录, 有效绕过自动化工具检测。

思路

PC端打开手机淘宝的搜索页链接,在开发者工具中搜索到商品API,是一个GET请求。

请求参数很多,其中最重要的三个参数为t、data、sign:

t:  13位时间戳,很容易构造。

data:  data参数在搜索链接重定向的url源码中,正则匹配获取。

重点为sign参数。搜索API的initiator 调用栈可以找到sign参数的js生成函数,
断点调试后可知该生成函数需要的变量字符串为 'cookies的token' + '&' + t + appKey + '&' + data。
appKey为一个固定值'12574478',t、data构造也很简单,所以接下来只要调用execjs库执行sign参数的js生成函数即可。

解释说明

搜索链接为手淘搜索分享的链接,未实现搜索链接的关键词构造。

cookies中的token有时效性,过期时页面响应为“令牌过期”,此时需要更新cookies。

脚本中代理未启用,如需大量爬取,请使用稳定高效的代理。

结果展示

image image image image

公告

该脚本仅供学习交流,切勿用作商业用途,否则后果自负。

taobao's People

Contributors

xzh0723 avatar vincent2014 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.