Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web scraping 如果URL包含Puppeter中的函数_Web Scraping_Puppeteer - Fatal编程技术网

Web scraping 如果URL包含Puppeter中的函数

Web scraping 如果URL包含Puppeter中的函数,web-scraping,puppeteer,Web Scraping,Puppeteer,因此,如果URL包含以下内容,我将尝试让我的代码执行某些操作: 在“?”之后可以有任何东西,所以我只希望它能够识别”https://kith.com/throttle/queue?" 我正在使用木偶演员,希望它能像这样工作: 如果URL包含'https://kith.com/throttle/queue?'然后等待它通过队列(page.waitForNavigation({waitUntil:'networkidle2'})将用于等待它通过队列 Else(如果URL不包含该内容):不执行任何操作

因此,如果URL包含以下内容,我将尝试让我的代码执行某些操作:

在“?”之后可以有任何东西,所以我只希望它能够识别”https://kith.com/throttle/queue?"

我正在使用木偶演员,希望它能像这样工作: 如果URL包含'https://kith.com/throttle/queue?'然后等待它通过队列
(page.waitForNavigation({waitUntil:'networkidle2'})
将用于等待它通过队列


Else(如果URL不包含该内容):不执行任何操作并转到下一行代码

很难理解如何获取此URL,但如果这是当前页面的URL,则可以尝试以下操作:

consturl=wait page.evaluate(()=>location.href);
if(url.startsWith('https://kith.com/throttle/queue?')) {
//等待导航。
}否则{
//什么也不做。
}

你能举一个“可以是任何东西”的例子吗?你不是指URL参数而不是函数吗?也许是
URL.starsWith('https://kith.com/throttle/queue?')
足够了吗?你能举个例子吗?我该如何将其实现到一个ty循环中?哇,这很有效!谢谢!队列没有结束,所以我无法测试它,但在那一点上它没有中断(以前是这样的).谢谢!我现在该如何处理URL的结尾?URL.endsWith?是的。看到了吧,这是关于字符串而不是URL的。谢谢!最后一件事:你能看看这个吗?