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
XiaoCilang
V2EX  ›  Python

Python 爬虫爬取头条街拍的问题

  •  
  •   XiaoCilang · 2019-05-28 16:46:04 +08:00 · 2115 次点击
    这是一个创建于 1793 天前的主题,其中的信息可能已经有所发展或是发生改变。
    各位大佬,请教个问题,使用 requests 时:
    s = requests.get('https://www.toutiao.com/api/search/content/?keyword=%E8%A1%97%E6%8B%8D&aid=24&app_name=web_search&offset=0&format=json&autoload=true&count=20&en_qc=1&cur_tab=1&from=search_tab&pd=synthesis&timestamp=',int(time.time()))
    发送上面这个请求后,调用 s.json()返回的信息不是正确的网页信息,但是把 keyword 后面的‘&’(即 a 前面的&)去掉后就可以正确抓取到,而且把 keyword 这个参数和其他参数换位置后不管怎么样都抓取不到。
    用开发者工具查看头条街拍的 Request URL 是: https://www.toutiao.com/api/search/content/?aid=24&app_name=web_search&offset=0&format=json&keyword=%E8%A1%97%E6%8B%8D&autoload=true&count=20&en_qc=1&cur_tab=1&from=search_tab&pd=synthesis&timestamp=1559032961134,实在搞不懂,请各位大佬帮忙。
    3 条回复    2019-05-28 17:39:53 +08:00
    Achilless
        1
    Achilless  
       2019-05-28 17:00:02 +08:00
    爬街拍多没劲,爬 h 图啊哈哈
    XiaoCilang
        2
    XiaoCilang  
    OP
       2019-05-28 17:35:03 +08:00
    @Achilless 新手,慢慢来哈哈哈。
    tikazyq
        3
    tikazyq  
       2019-05-28 17:39:53 +08:00
    不可能吧,API 接口文档先研究清楚一下撒

    顺便打个广告开源爬虫平台 Crawlab, https://github.com/ tikazyq/crawlab

    Crawlab 是一个专注于爬虫的集成了爬虫管理、任务调度、任务监控、数据分析等模块的分布式爬虫管理平台,非常适合对爬虫管理、爬虫工程化有要求的开发者及企业。

    最近开发的可配置爬虫正好解决你配置爬虫的问题,1-3 分钟编写好一个可运行的爬虫。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1128 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:47 · PVG 02:47 · LAX 11:47 · JFK 14:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.