Answered by ZUPAN | Dec. 09, 2019 12:17
Unfortunately, you have to obtain a tourist (L) visa in advance. The reason is simple. You cannot have two consecutive stops within two different Chinese transit areas (Beijing and Shanghai in your case) an remain eligible for any kind of visa free transit scheme.
In reality, you could travel visa free, but that requires that you leave China to some neighboring country and to return from that country back to China. For example:
US - Beijing - Seoul (South Korea) - Shanghai - US
This itinerary would allow you to enjoy 144 hour visa free transit in both Beijing and in Shanghai area. When you are in Shanghai area, you can also visit Suzhou, Wuxi and Hangzhou.
So, you will have to decide whether you will make your itinerary a bit creative and probably a bit more expensive or you will obtain a Chinese visa and travel throughout the country in the way as you wish. If you ask me, I would suggest you to obtain a visa, especially because US citizens are eligible for 10 year multiple entry visa, especially convenient if you intend to visit China during the next several years.