V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
a6377508
V2EX  ›  问与答

请问为什么如下 JavaScript 语句不起作用?

  •  
  •   a6377508 · 2017-07-31 19:23:48 +08:00 · 1732 次点击
    这是一个创建于 2433 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我想爬取汽车之家的信息,预想如下语句返回的是“一汽”,但并没有。 说明:“一汽”是通过伪元素添加的,所以并不只 DOM 中。

    爬取地址: http://car.autohome.com.cn/config/series/3170.html

    window.getComputedStyle(document.querySelector('span.hs_kw15_configpl'), ':before').getPropertyValue('content')

    2 条回复    2017-07-31 20:26:17 +08:00
    wly19960911
        1
    wly19960911  
       2017-07-31 20:03:11 +08:00
    控制台输入 window.getComputedStyle
    结果输出是 ƒ (element, pseudoElt){if ( pseudoElt!=undefined && typeof( pseudoElt)=='string' && pseudoElt.toLowerCase().indexOf(':before')>-1){var obj = {};obj.getPropertyValue = function (x) { return x; };return …

    看了下。貌似 getComputedStyle 被覆写了
    wly19960911
        2
    wly19960911  
       2017-07-31 20:26:17 +08:00
    帮你找了下,他们的 window.getComputedStyle 方法被覆写并且被替换成了 window.hs_fuckyou 方法 hhh
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2813 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 11:46 · PVG 19:46 · LAX 04:46 · JFK 07:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.