V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2019-01-01 17:07:59 +08:00 · 1988 次点击
    这是一个创建于 1940 天前的主题,其中的信息可能已经有所发展或是发生改变。
    新手刚开始学习爬虫不久,现在正在尝试使用 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 条回复    2019-01-21 11:53:56 +08:00
    j0hnj
        1
    j0hnj  
       2019-01-01 18:05:25 +08:00
    为啥不直接用 graphql 接口?
    autulin
        2
    autulin  
       2019-01-02 09:00:41 +08:00 via iPhone
    会不会没有渲染完你就去获取了?给个延时试试?
    ZintrulCre
        3
    ZintrulCre  
    OP
       2019-01-21 11:53:56 +08:00
    用接口解决了问题。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5409 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 08:36 · PVG 16:36 · LAX 01:36 · JFK 04:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.