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

PuppeteerUtil.useProxy使用代理失败 #20

Open
wings-xue opened this issue Sep 3, 2020 · 0 comments
Open

PuppeteerUtil.useProxy使用代理失败 #20

wings-xue opened this issue Sep 3, 2020 · 0 comments

Comments

@wings-xue
Copy link

wings-xue commented Sep 3, 2020

    AddToQueue,
    AddToQueueData,
    appInfo,
    DbHelperUi,
    FromQueue,
    Job,
    JobOverride,
    Launcher,
    OnStart,
    Page,
    PuppeteerUtil,
    PuppeteerWorkerFactory,
    RequestUtil,
    OnTime
} from "ppspider";

class TestTask {

    @OnStart({
        urls: [
            "https://api.ipify.org/?format=json"
        ],
        parallel: 3,
        exeInterval: 1000,
        timeout: 60000
    })
    async onStart(page: Page, job: Job) {
        page.setDefaultTimeout(60000);
        page.setDefaultNavigationTimeout(60000);
        await PuppeteerUtil.setImgLoad(page, false);
        // await PuppeteerUtil.useProxy(page, "http://127.0.0.1:2007");
        await PuppeteerUtil.useProxy(page, "socks://27.157.253.114:18917");
        await page.goto(job.url);
        console.log(await page.evaluate(() => document.title));
    }

}

@Launcher({
    workplace: "workplace",
    tasks: [
        TestTask
    ],
    workerFactorys: [
        new PuppeteerWorkerFactory({
            headless: false,
            devtools: true
        })
    ],
    webUiPort: 9001
})
class App {}

按照例子写的使用代理的代码。但是调试发现请求失败,无论怎么换代理,并且代理已经通过测试确实可以使用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant