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

[Fixed] Chưa chạy được từ page 0 (chính là homepage) #3

Open
ngminhtrung opened this issue Mar 10, 2018 · 0 comments
Open

Comments

@ngminhtrung
Copy link
Contributor

ngminhtrung commented Mar 10, 2018

Vấn đề: Hiện tại mới chạy được từ page số 2 đến page cuối cùng. Page số 1 (cũng là page 0, và là homepage) bị bỏ qua.

Cách giải quyết: Với homepage, đường link là: https://vinacode.net/, với trang ngay tiếp theo, đường linh là https://vinacode.net/page/2, và con số đánh tiếp tục tăng dần. Vậy xử lý như sau:

Code cũ:

    for (let pageNo = 2; pageNo < 21; pageNo++) {
        let pageNumber = (pageNo === 1 ) ? '' : `page/${pageNo}`; 
        await page.goto(`https://vinacode.net/page/${pageNumber}`);
        // đoạn code khác
   }

Code mới:

    for (let pageNo = 1; pageNo < 21; pageNo++) {
        let pageNumber = (pageNo === 1 ) ? '' : `page/${pageNo}`;
        await page.goto(`https://vinacode.net/${pageNumber}`);
        // đoạn code khác
   }
@ngminhtrung ngminhtrung changed the title Chưa chạy được từ page 0 (chính là homepage) [Fixed] Chưa chạy được từ page 0 (chính là homepage) Mar 12, 2018
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