小编naq*_*hab的帖子

在Visual Studio Code中调试Scrapy项目

我在Windows机器上安装了Visual Studio Code,并在上面制作了新的Scrapy Crawler。搜寻器工作正常,但我想调试代码,为此我将其添加到launch.json文件中:

{
    "name": "Scrapy with Integrated Terminal/Console",
    "type": "python",
    "request": "launch",
    "stopOnEntry": true,
    "pythonPath": "${config:python.pythonPath}",
    "program": "C:/Users/neo/.virtualenvs/Gers-Crawler-77pVkqzP/Scripts/scrapy.exe",
    "cwd": "${workspaceRoot}",
    "args": [
        "crawl",
        "amazon",
        "-o",
        "amazon.json"
    ],
    "console": "integratedTerminal",
    "env": {},
    "envFile": "${workspaceRoot}/.env",
    "debugOptions": [
        "RedirectOutput"
    ]
}
Run Code Online (Sandbox Code Playgroud)

但是我无法达到任何断点。PS:我从这里获取了JSON脚本:http : //www.stevetrefethen.com/blog/debugging-a-python-scrapy-project-in-vscode

python visual-studio scrapy python-3.x visual-studio-code

3
推荐指数
4
解决办法
2598
查看次数

Puppeteer 一次为每个文件打开 chrome 实例

我正在尝试自动化一个工作流程,其中我有一个目录中的文件列表,并将它们放在一个数组中。然后对于数组中的每个文件,我调用 Chrome 自动化函数。

const path = require('path');
const chalk = require('chalk');
const puppeteer = require('puppeteer');

module.exports = {
    generateOutput : async(fileName, url = "https://example.com/") => {
        const filePath = path.join(process.cwd(), fileName);
        const outputFilePath = path.join(process.cwd(), "OutputFiles");
        try{
            const browser = await puppeteer.launch({headless: false});
            process.setMaxListeners(0);
            const page = await browser.newPage();
            await page._client.send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: outputFilePath});
            page.on('dialog', async dialog => {
                console.log(chalk.magenta("Error Occured: " + dialog.message()));
                await dialog.dismiss();
                await browser.close();
            });
            await page.goto(url, {waitUntil: 'networkidle2'});
            await page.click('#ui-id-9');
            await page.click('#ui-id-18');
            await page …
Run Code Online (Sandbox Code Playgroud)

javascript windows node.js async-await puppeteer

2
推荐指数
1
解决办法
1593
查看次数