In general, I think late April and mid Oct are good periods. On one trip to both Shanghai and Beijing in late April, I never saw sunshine (it was covered by haze and smog) for 3 days in SH. Of the 3 days in Beijing, I was sooooo happy that 1 day blessed with blue sky and a bit of white clouds. Never experienced that in my several trips to the capital city.