I'm 99.9% sure you could pull this off if you wanted to. However, given that PRC regulations change daily and tend to be ambiguous/arbitrary, I'd probably get a letter from your consulate to be safe. (I would do this even if taking advantage of the Shanghai 48 hour rule.) Just out of curiosity, why do you want to transit at PEK without stopping? If you just want to transit, there are much nicer airports in which to do so(SIN, HKG, SEL, etc.). Plus, Beijing is an interesting, if not downright pleasent, city that deserves a visit.