推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
akmonde
V2EX  ›  Python

[V 币感谢] headless 浏览器是否有办法抓取网页中的 ajax 请求,并 js 模拟发送么

  •  
  •   akmonde · Jan 15, 2019 · 3580 views
    This topic created in 2819 days ago, the information mentioned may be changed or developed.

    RT,最近玩 scrapy 有这方面的需求,不知道有没有办法以 middlewares 的手段去抓取 JS 标签里的 ajax 请求,并模拟发送。 是否只能手动提取,再组合参数发送?

    在线等大佬解答,感谢!!

    6 replies  •  2019-01-17 13:44:37 +08:00
    epkT6QJ3RSaz6AnJ
        2
    epkT6QJ3RSaz6AnJ  
       Jan 15, 2019
    目前只想到可以搞个 polyfill,然后拦截
    mYYnSmiTEQWcCwAr
        3
    mYYnSmiTEQWcCwAr  
       Jan 15, 2019
    hookajax 以及 fetch 的 polyfill 就能在 js 层面把请求拦下来了
    不过浏览器都能控制的话 为啥不直接看浏览器开发人员工具提供的 network 呢
    wangtao7
        4
    wangtao7  
       Jan 15, 2019
    akmonde
        5
    akmonde  
    OP
       Jan 17, 2019
    @epkT6QJ3RSaz6AnJ 您的意思是拦截器监控再复现?但是我在随机爬行某个网站时不一定能触发该 js 函数,我这算是黑盒,白盒的应该不太适用。
    akmonde
        6
    akmonde  
    OP
       Jan 17, 2019
    @cy97cool
    @wangtao7
    感谢两位的回复,两位说的都是拦截器吧,不过我黑盒爬虫去爬不一定能触发 ajax,靠这个拦截复现不太现实。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   750 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 22:35 · PVG 06:35 · LAX 15:35 · JFK 18:35
    ♥ Do have faith in what you're doing.