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

初学 Python 自己写了个程序爬自己博客

  •  
  •   lzj307077687 · Aug 21, 2019 · 3083 views
    This topic created in 2600 days ago, the information mentioned may be changed or developed.

    https://github.com/straightedge4life/roblograbber
    有什么不足麻烦大佬们指正

    7 replies  •  2019-08-22 17:57:22 +08:00
    CallMeReznov
        1
    CallMeReznov  
       Aug 21, 2019
    看到楼主头像,我下意识就想脱裤子.
    Iamnotfish
        2
    Iamnotfish  
       Aug 21, 2019
    干嘛存 SQL,存 CSV,TXT 不是更方便吗(认真脸
    wzwwzw
        3
    wzwwzw  
       Aug 22, 2019   ❤️ 1
    with ThreadPoolExecutor(max_workers) as pool:
    for item in args :
    future = pool.submit(fn , **item)
    futures.append(future)
    pool.shutdown()

    用了 with 会自动帮你上下文管理的 pool 的,不需要写 shutdown()
    lzj307077687
        4
    lzj307077687  
    OP
       Aug 22, 2019
    @Iamnotfish #2 一开始是写入 TXT 的 确实简单很多
    现在存 MYSQL 主要是之前安装 mysqlclient 填了个坑
    感觉不稍微试用下的话有点辜负之前的折腾 嘿嘿
    lzj307077687
        5
    lzj307077687  
    OP
       Aug 22, 2019
    @wzwwzw #3 又学到了~ 谢谢指正
    locoz
        6
    locoz  
       Aug 22, 2019   ❤️ 1
    看起来你之前应该不是写 Python 的?有些地方 PEP8 规范可以注意一下。
    然后为了提高效率可以试试 ayncio,用 aiohttp 这类异步的库。
    还有就是像 type(headers) is dict 这种可以写成 isinstance(headers, dict)。
    lzj307077687
        7
    lzj307077687  
    OP
       Aug 22, 2019
    @locoz #6 谢回复指导,下班回去了解一下~
    现在主要是写 PHP。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   768 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 20:24 · PVG 04:24 · LAX 13:24 · JFK 16:24
    ♥ Do have faith in what you're doing.