爬虫 google maps接口分析

关键词搜索接口分析

分析搜索接口

接口查找

图1

接口分析对比差异

图二

分析返回文本

图三
图四

google maps的详情页的URL拼接

图五

key_list_9_2 = round(data[14][9][2], 7)
key_list_9_3 = round(data[14][9][3], 7)
key_list_10 = data[14][10]
key_list_11 = data[14][11]
url = 'https://www.google.es/maps/place/{}/data=!4m5!3m4!1s{}!8m2!3d{}!4d{}?authuser=0&hl=en&rclk=1'.format(key_list_11.replace(' ', '+'), key_list_10, key_list_9_2, key_list_9_3)

google maps如何判断是否还有下一页

图六

分析详情页接口(主要分析Temporarily closed值怎么来的)

请求主页获得主要数据
图七

主要在一个js文件里面
图八
抠出来的部分js代码

var Sma = class {
    constructor(a, b) {
        this.N = a;
        this.O = b;
        this.H = a[b]
    }
    nb(a) {
        var b = this.H && this.H[a.Xk];
        if (b = null == b ? null : a.PK.O(b))
            return b;
        b = [];
        this.H || (this.N[this.O] = this.H = {});
        this.H[a.Xk] = b;
        return a.PK.O(b)
    }
};
function initialize (a, b, c, d) {
    this.V = a = a || [];
    if (a.length) {
        var e = a.length - 1
        , f = bj(a[e]);
        e = f ? a[e] : {};
        f && a.length--;
        f = 0;
        var h;
        for (var g in e) {
            const h = + g;
            h <= b ? (a[h - 1] = e[g],
            delete e[g]) : f++
        }
        for (let h = 0, l = 0; d && l < d.length; )
            h += d[l++],
            g = d[l++],
            f += oga(h, g, a, e),
            h += g;
        a.length > b && (f += oga(b, a.length - b, a, e),
        a.length = b);
        f && (a[b] = e)
    }
    c && (this.W = new Sma(this.V,b))
};
function oga (a, b, c, d) {
    let e = 0;
    for (; 0 < b; --b,
    ++a)
        null != c[a] && (d[a + 1] = c[a],
        delete c[a],
        e++);
    return e
};
function bj (a) {
    return null != a && typeof a === "object" && !Array.isArray(a) && a.constructor === Object
};
function ssb (a) {
    initialize(a, 1)
};
function ana (a, b, c) {
    a = a.V[b];
    return null != a ? a : c
};
function K(a, b, c) {
    return !!ana(a, b, c)
};
function JD (a) {
    return new ssb(a.V[160])
};
function eE (a) {
    return K(a, 23) || K(JD(a), 0)
};

经过分析js文件中的代码我们发现主要通过判断传入的object中的a.V[160]是否为1从判断这个Temporarily closed
图九
分析发现object a中的数据就是从图七中的主要数据传入的

page = etree.HTML(response.text)
a = page.xpath('/html/head/script/text()')
for b in a:
    if '(function(){window.APP_OPTIONS=' in b:
        c = b
        break
if c:
    e = json.loads(re.findall('window.APP_INITIALIZATION_STATE=(.*?);window.APP_FLAGS', c)[0])
    d = json.loads(e[3][6].replace(")]}'", ''))
else:
    return False

在这里插入图片描述
在这里插入图片描述

到此完结

完整代码链接

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值