小编glh*_*e13的帖子

如何在 Puppeteer 中重新加载页面?

我想在页面加载不正确或遇到问题时重新加载页面。我试过了,page.reload()但没有用。

for(const sect of sections ){

            // Now collect all the URLs
            const appUrls = await page.$$eval('div.main > ul.app-list > li > div.app-info a.app-info-icon', links => links.map(link => link.href));

            // Visit each URL one by one and collect the data
            for (let appUrl of appUrls) {
                var count = i++;
                try{
                    await page.goto(appUrl);
                    const appName = await page.$eval('div.det-name-int', div => div.innerText.trim());
                    console.log('\n' + count);
                    console.log(appName);
                } catch(e){
                    console.log('\n' + count);
                    console.log('ERROR', e);
                    await page.reload();
                }

            }

        }
Run Code Online (Sandbox Code Playgroud)

它给了我这个错误: …

javascript chromium node.js puppeteer

23
推荐指数
3
解决办法
3万
查看次数

如何在Python中比较列表中的多个日期?

我想知道如何比较列表中的日期。我想提取“最早”的日期。(我做了一个 for 循环,因为我必须用“-”替换一些字符)

comment_list = comment_container.findAll("div", {"class" : "comment-date"})
D =[]

  for commentDate in comment_list:
    year, month, day = map(int, commentDate.split('-'))
    date_object = datetime(year, month, day)
    date_object = datetime.strptime(commentDate, '%Y-%m-%d').strftime('%Y-%m-%d')   
    D.append(date_object)

print(D)
Run Code Online (Sandbox Code Playgroud)

输出:

['2018-06-26', '2018-04-01', '2018-07-19', '2018-04-23', '2018-08-25', '2018-06-08', '2018-06-14', '2018-07-08', '2019-03-15', '2019-03-15', '2019-03-15', '2019-03-15', '2019-03-15']
Run Code Online (Sandbox Code Playgroud)

我想提取最早的日期:

例如。

'2018-04-01'

python list beautifulsoup web-scraping

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