Giter VIP home page Giter VIP logo

wereadscan's Introduction

WeReadScan

Codacy Badge GitHub last commit GitHub code size in bytes GitHub top language pip

About

一个用于的将微信读书上的图书扫描转换本地PDF的爬虫库.

谈谈为何而开发

不得不说,“微信读书”是一个很好的平台。但是美中不足很明显,用户购买了图书资源,但是只能在“微信读书”的Application中阅读或者做一些文字批注╮(╯▽╰)╭,这些功能相较于购买的纸质书籍显然是不足的。比如,作者就习惯于用iPad的相关notebook类app做笔记,而“微信读书”并没有适配pencil做handwriting笔记的功能。

因此,既然“微信读书”没有提供,那只好自己解决了。于是,经过2天的开发,终于有了这个爬虫脚本,也可以开心地做手写笔记了o( ̄▽ ̄)ブ

Get started

pip install WeReadScan

本项目需要使用selenium,需要对selenium具备基础的了解

Demo

话不多说,直接上代码

from selenium.webdriver import Chrome, ChromeOptions
from WeReadScan import WeRead

# 重要!为webdriver设置headless
chrome_options = ChromeOptions()
chrome_options.add_argument('--headless')

# 启动webdriver(--headless)
headless_driver = Chrome(options=chrome_options)

# debug 模式启动,可以保留png缓存
with WeRead(headless_driver,debug=True) as weread:
    # 重要!登陆
    weread.login()
    # 爬去指定url对应的图书资源并保存到当前文件夹
    weread.scan2pdf('https://weread.qq.com/web/reader/2c632ef071a486a92c60226')

扫描结果样例:

几点说明:

  1. webdriver 需要 无头(headless) 模式启动
  2. 只有登陆后,才能扫描完整的图书资源;若不登陆,也可以扫描部分无需解锁的部分

API Reference

WeRead

WeReadScan.WeRead(headless_driver)

微信读书网页代理,用于图书扫描

Args

  • headless_driver: 设置了headless的Webdriver示例

Returns

  • WeReadInstance

Usage

chrome_options = ChromeOptions()
chrome_options.add_argument('--headless')
headless_driver = Chrome(chrome_options=chrome_options)
weread = WeRead(headless_driver)

Login

WeReadScan.WeRead.login(wait_turns=15)

展示二维码以登陆微信读书

Args

  • wait_turns: 登陆二维码等待扫描的等待轮数

Usage

weread.login()

Scan2pdf

WeReadScan.WeRead.scan2pdf(self, book_url, save_at='.', binary_threshold=95, quality=90, show_output=True,font_size_index=1)

扫面微信读书的书籍转换为PDF并保存本地

Args

参数名 类型 默认值 描述
book_url str 必填 扫描目标书籍的URL
save_at str '.' 保存地址
binary_threshold int 200 二值化处理的阈值
quality int 95 扫描PDF的质量
show_output bool True 是否在该方法函数结束时展示生成的PDF文件
font_size_index int 1 设置字号大小(对应微信读书字号)

Usage

weread.scan2pdf('https://weread.qq.com/web/reader/a57325c05c8ed3a57224187kc81322c012c81e728d9d180')

Disclaimer

  • 本脚本仅限用于已购图书的爬取,用于私人学习目的,禁止用于商业目的和网上资源扩散,尊重微信读书方面的利益
  • 若User使用该脚本用于不当的目的,责任由使用者承担,作者概不负责

Stargazers over time

Stargazers over time

wereadscan's People

Contributors

algebra-fun avatar codacy-badger avatar imgbotapp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.