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] Không đặt được biến global để lưu trữ kết quả của toàn bộ 20 trang #5

Open
ngminhtrung opened this issue Mar 10, 2018 · 1 comment

Comments

@ngminhtrung
Copy link
Contributor

Vấn đề:
Hiện tại dữ liệu lấy từ mỗi trang phải xuất ra ngay, trong khi nhu cầu là đặt 1 mảng rỗng bên ngoài vòng for. Mỗi vòng lặp, khi lấy được dữ liệu của 1 trang rồi, thì tống vào cái mảng rỗng ở trên. Nếu được thế thì kết quả cuối chứa toàn bộ kết quả của 20 trang, thay vì lắt nhắt từng trang 1. Bất chấp việc khai báo mảng rỗng bên ngoài kia dùng var hay let, thì cuối cùng đều bị báo lỗi "undefined".

ngminhtrung added a commit that referenced this issue Mar 12, 2018
fix url of homepage and set Useragent

Ref #5
@ngminhtrung
Copy link
Contributor Author

Giải quyết:

Do cách truyền variable vào hàm page.evaluate() của Puppeteer. Xem thêm ở bài [Puppeteer: pass variable in .evaluate(https://stackoverflow.com/questions/46088351/puppeteer-pass-variable-in-evaluate)]

@ngminhtrung ngminhtrung changed the title Không đặt được biến global để lưu trữ kết quả của toàn bộ 20 trang [Fixed] Không đặt được biến global để lưu trữ kết quả của toàn bộ 20 trang 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