【发布时间】:2020-08-30 05:19:26
【问题描述】:
我正在做https://fireship.io/lessons/web-scraping-guide/ 项目,我是网络抓取和firebase 的初学者。我已经到了“npm run serve”部分。但是你如何传入像 { "text": "https://fireship.io and https://www.instagram.com" } 这样的对象体?在运行 'npm run serve' 之前,我是否将其输入到终端窗口中,是否将其放入 index.js 文件中?我没有使用视频中提到的“失眠”软件,我也不知道它是什么。我在Mac上。 我不明白如何实际使用这两个网络抓取功能。谁能简单解释一下?附件是我的终端窗口中的错误。谢谢你的帮助!!
i functions: Beginning execution of "scraper"
> (node:26619) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token o in JSON at position 1
> at JSON.parse (<anonymous>)
> at /Users/stanleyjeong/Desktop/_CODING/web-scraper/fireship-webscraper/functions/index.js:121:27
> at cors (/Users/stanleyjeong/Desktop/_CODING/web-scraper/fireship-webscraper/functions/node_modules/cors/lib/index.js:188:7)
> at /Users/stanleyjeong/Desktop/_CODING/web-scraper/fireship-webscraper/functions/node_modules/cors/lib/index.js:224:17
> at originCallback (/Users/stanleyjeong/Desktop/_CODING/web-scraper/fireship-webscraper/functions/node_modules/cors/lib/index.js:214:15)
> at /Users/stanleyjeong/Desktop/_CODING/web-scraper/fireship-webscraper/functions/node_modules/cors/lib/index.js:219:13
> at optionsCallback (/Users/stanleyjeong/Desktop/_CODING/web-scraper/fireship-webscraper/functions/node_modules/cors/lib/index.js:199:9)
> at corsMiddleware (/Users/stanleyjeong/Desktop/_CODING/web-scraper/fireship-webscraper/functions/node_modules/cors/lib/index.js:204:7)
> at /Users/stanleyjeong/Desktop/_CODING/web-scraper/fireship-webscraper/functions/index.js:118:5
> at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:570:20
> (node:26619) 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:26619) [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.
⚠ functions: Your function timed out after ~60s. To configure this timeout, see
https://firebase.google.com/docs/functions/manage-functions#set_timeout_and_memory_allocation.
> /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:619
> throw new Error("Function timed out.");
> ^
>
> Error: Function timed out.
> at Timeout._onTimeout (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:619:23)
> at listOnTimeout (internal/timers.js:549:17)
> at processTimers (internal/timers.js:492:7)
【问题讨论】:
标签: javascript macos firebase web-scraping terminal