He’s a real book worm!

A serial thief who repeatedly stole books from the New York Public Library and sold them to unwitting downtown stores was busted after a furious shopkeeper laid a trap for him, The Post has learned.

Andrew Hansen — who is banned from the library — saw his criminal career come to a thrilling end in the East Village Monday night as he tried to off-load a batch of ill-gotten goods.

Donald Davis, owner of East Village Books at 99 St. Marks Place, said he had been fooled by Hansen, 27, before and was prepared this time around.

“He walks in. I had gone to dinner. My friend was watching the store for me, [and] he called me on my cellphone,” Davis recalled yesterday. “We had a code set up so that he would say, ‘Where’s my delivery?’ Then I knew the guy was there.”

When he got back to his shop, Davis confronted Hansen, who has a lengthy rap sheet.

“He would tear all the labels off of them so it would look like they were not from the library, [but] there were remnants of the stickers that used to be on the books,” said Davis, adding that the books were mostly graphic novels that go for up to $40 each.

“He starts to move to the door. He wants to get out, and he’s trying to leave. I said, ‘You’re not going anywhere. The police are on their way!’ ” Davis recalled.

He said he pushed Hansen into a chair, and “we got into a big tussle.”

“The guy tries to push me, [and] I slam into the floor,” Davis said. “I’m on top of him. He tries to get up. I was a high-school wrestler, so every time he tried to get up, I’m putting the riding move on him.”

Cops showed up a few minutes later and arrested Hansen.

“There’s no other situation where I would do this. I was so angry that he was stealing from the library,” Davis said. “The library is just a very important piece of our community.”

Hansen, authorities said, was well known to NYPL gumshoes and local bookstores.

Sources said the NYPL had sent a picture of Hansen, who used to work in the publishing industry before developing a drug problem, to bookshops.

Library security had banned him and confiscated three library cards he had been issued, and he was also banned from the Strand bookstore in Union Square, they said.

Hansen was charged with burglary and criminal possession of stolen property and is being held at Rikers on $7,500 bond.

His rap sheet dates to 2003 and includes drug and weapons arrests and multiple busts for burglary, sources said.

In September 2009, he was busted in Union Square Park for cutting labels off stolen library books. Two months later, he was nabbed for shoplifting from a Barnes & Noble.

Last July, he was arrested inside Tompkins Square library while attempting to remove library books, the sources said.

Davis said he hopes Monday’s bust will serve as a warning to would-be book thieves.

“There’s going to be a lot of anger when this gets out,” Davis said. “People will think twice about selling library books.”

Additional reporting by Rebecca Rosenberg