ourongxing / web-printer Goto Github PK
View Code? Open in Web Editor NEWA printer that can print multiple web pages as one pretty PDF
License: MIT License
A printer that can print multiple web pages as one pretty PDF
License: MIT License
可不可以转一个Markdown格式,pdf格式中的字体没办法自行更改,现有pdf的字体个人感觉不是很美观
按照 README 中的案例来运行的
import { Printer } from "@web-printer/core"
import zhihu from "@web-printer/zhihu"
new Printer()
.use(
zhihu({
url: "https://www.zhihu.com/collection/19561986"
})
)
.print("值得回头看几遍")
console.log(zhihu) 输出如下
{ default: [Getter] }
所以代码修改成如下可以运行了
- zhihu({
+ zhihu.defalt({
hi,我做了两次尝试,第一次使用 vitepres 插件,第二次使用阮一峰插件,其他设置都采用默认的设置
运行 pnpm print 后,日志为
Fetching Pages Info...(node:92391) UnhandledPromiseRejectionWarning
(Use node --trace-warnings ...
to show where the warning was created)
(node:92391) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:92391) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
userData 内容为空,无 pdf 生成。请问原因可能是什么呢?
目前安装了 Chrome 浏览器,Chrome 浏览器已经登录了知乎,生成的 PDF 中有的答案是正常的内容,有的答案都是 知乎的登录页面,显示知乎的登录页面
测试爬取的知乎专栏为 https://www.zhihu.com/collection/20328337
目前看是爬取的目录是重复的,爬取到了整个专栏的数量,但是因为 没有设置 maxPages,导致一直重复爬取的第一页的数据,然后不断重复爬取第一页知道数量达到整个专栏的文章总数量
爬取到后面,出现了知乎的检测
报错信息:
Fetching Pages Info...node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
Protocol error (Browser.setDownloadBehavior): 'Browser.setDownloadBehavior' wasn't found
node: 18.12
chrome: 最新版
I don't know how to use it after reading the introduction
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.