bash version (simplified. not use cache, but you can control max page number)