a6377508
V2EX  ›  问与答

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

  •  
  •   a6377508 · Jul 31, 2017 · 2652 views
    This topic created in 3235 days ago, the information mentioned may be changed or developed.

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

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

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

    2 replies    2017-07-31 20:26:17 +08:00
    wly19960911
        1
    wly19960911  
       Jul 31, 2017
    控制台输入 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  
       Jul 31, 2017
    帮你找了下,他们的 window.getComputedStyle 方法被覆写并且被替换成了 window.hs_fuckyou 方法 hhh
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5935 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 02:53 · PVG 10:53 · LAX 19:53 · JFK 22:53
    ♥ Do have faith in what you're doing.