Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throw new Error(Directory ${absoluteDirectoryPath} exists); #537

Closed
obsidianart opened this issue Sep 15, 2023 · 7 comments
Closed

throw new Error(Directory ${absoluteDirectoryPath} exists); #537

obsidianart opened this issue Sep 15, 2023 · 7 comments
Labels

Comments

@obsidianart
Copy link

Configuration

version: [result of npm ls website-scraper --depth 0 command]
website-scraper@5.3.1

options: [provide your full options object]

import scrape from 'website-scraper'; // only as ESM, no CommonJS
const options = {
  urls: ['https://www.imagzle.com'],
  directory: './docs'
};

// with async/await
const result = await scrape(options);

// with promise
scrape(options).then((result) => {});

Description

The script is throwing an error. I did try to delete the folder but the error happens regardless after the script creates the folder

Expected behavior: [What you expect to happen]
No errors
Actual behavior: [What actually happens]
stefanosolinas@stefanos-MacBook-Pro-2 scraper % node index.js
file:///Users/stefanosolinas/HDD/GIT/ollama%20private/scraper/node_modules/website-scraper/lib/plugins/save-resource-to-fs-plugin.js:16
throw new Error(Directory ${absoluteDirectoryPath} exists);
^

Error: Directory /Users/stefanosolinas/HDD/GIT/ollama private/scraper/docs exists
at file:///Users/stefanosolinas/HDD/GIT/ollama%20private/scraper/node_modules/website-scraper/lib/plugins/save-resource-to-fs-plugin.js:16:11
at Scraper.runActions (file:///Users/stefanosolinas/HDD/GIT/ollama%20private/scraper/node_modules/website-scraper/lib/scraper.js:229:20)
at Scraper.scrape (file:///Users/stefanosolinas/HDD/GIT/ollama%20private/scraper/node_modules/website-scraper/lib/scraper.js:276:15)
at default (file:///Users/stefanosolinas/HDD/GIT/ollama%20private/scraper/node_modules/website-scraper/index.mjs:4:30)
at file:///Users/stefanosolinas/HDD/GIT/ollama%20private/scraper/index.js:11:1

Node.js v20.3.0

Additional Information

[Any additional information, configuration or data that might be necessary to reproduce the issue]

@aivus
Copy link
Member

aivus commented Sep 17, 2023

Hello @obsidianart 👋

Seems strange.

Could you please check that there are no other processes of the module running?

Try to remove directory /Users/stefanosolinas/HDD/GIT/ollama private/scraper/docs, verify that it's removed and not re-created and then run the script.

@obsidianart
Copy link
Author

I restarted my machine, deleted docs, nothing else running, same error.

@aivus
Copy link
Member

aivus commented Oct 13, 2023

Try to use directory: './docs/' + new Date().getTime(),
It will create a directory inside the docs folder based on the time.

Please check and let me know do you have the same issue as above or not

@deweller
Copy link

I'm also having this same issue.

@tushar-rupani
Copy link

With the same options the files have been downloaded in the respected path you have mentioned for the first time with this code.

const result = await scrape(options);

and with the same options again you're using Promise .then() syntax. It will again try to upload files there - henceforth, it is causing that error. either we use async/await or promise.

@aivus
Copy link
Member

aivus commented Oct 31, 2023

Good catch @tushar-rupani !

I missed the fact that scraper called 2 times

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants