All districts in Shanghai should have branches of the Shanghai Library, and access is free. You can apply for a reader's card with your ID card. Deposit 100 yuan, common in all districts. You can borrow ten books at a time and renew them for up to 56 days.
Of course, you can go in and read books without a license, but you can't check them out. Some libraries have 24-hour reading rooms, but you have to swipe your reader card to get in. If you just want to read a book, I suggest going early. There are many people who are late, and there are no seats. For details, please search Minhang Branch of Shanghai Library on the map.