推荐学习书目
› 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
ZintrulCre
V2EX  ›  Python

关于使用 scrapy+splash 爬 leetcode 的问题

  •  
  •   ZintrulCre · Jan 1, 2019 · 2882 views
    This topic created in 2824 days ago, the information mentioned may be changed or developed.
    新手刚开始学习爬虫不久,现在正在尝试使用 splash 来爬取用 js 渲染的动态页面,比如从 https://leetcode.com/problemset/all/ 爬取各种题目信息。
    但是在 https://leetcode.com/problems/two-sum/ 这种页面中调用 response.xpath("//div[@class='css-1ponsav']")似乎并不能获取到任何信息,不知道是什么原因?
    同理在 https://leetcode.com/accounts/login/ 登陆界面里试图调用 SplashFormRequest.from_response(response,...)来进行登陆操作的时候也会返回 ValueError: No <form> element found in <200 https://leetcode.com/accounts/login/>,似乎并没有抓取到表格信息?
    本人不太了解前端,不知道这个跟 leetcode 用的 graphQL 有没有关系?还是因为其它原因?
    3 replies  •  2019-01-21 11:53:56 +08:00
    j0hnj
        1
    j0hnj  
       Jan 1, 2019
    为啥不直接用 graphql 接口?
    autulin
        2
    autulin  
       Jan 2, 2019 via iPhone
    会不会没有渲染完你就去获取了?给个延时试试?
    ZintrulCre
        3
    ZintrulCre  
    OP
       Jan 21, 2019
    用接口解决了问题。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2660 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 08:48 · PVG 16:48 · LAX 01:48 · JFK 04:48
    ♥ Do have faith in what you're doing.