BEIJING — Shanghai appeared on Wednesday to be making gradual progress in bringing coronavirus outbreaks under control, while Beijing continued finding more cases as it tries to test three times over five days nearly all of the capital’s 22 million residents.
Shanghai announced its lowest total for new cases in weeks: 12,309. Only 171 of those were detected among people still in the broader community. The rest were among people already in isolation as the contacts of previously infected people, and were less likely to infect others, according to municipal data.
Zhao Dandan, deputy director of the Shanghai Health Commission, told a news conference that the authorities would allow limited activities in areas with no more virus transmission outside of quarantine, but would maintain the lockdown of the rest of the city.
Beijing officials said that they had detected 46 further cases in the 23 hours through midafternoon Wednesday, as a giant P.C.R. testing program continues. Beijing has already processed 19.8 million tests from its initial round of testing, said Li Ang, deputy chief of the city’s quarantine and testing working group.
Beijing identified three more neighborhoods on Wednesday as high-risk and four more as medium-risk, a label that prompts lockdowns.
The scale of Beijing’s testing program is enormous. Folding tables have been set up every few blocks near large roads. Up to a half-dozen volunteers help to direct residents and take their names, and several medical workers perform the swift oral swabs.
Using so-called batch testing, numerous swabs are placed in pink liquid in a single test tube and sent to a lab. If the liquid tests positive for the presence of the virus, then the authorities contact each person who had a swab in the tube and conduct intensive nasal P.C.R. testing.
Mr. Li said that the city had mobilized 35,000 medical workers who take the samples and another 104,000 volunteers and other auxiliaries to help them.
At a curbside neighborhood testing site on Wednesday evening in Chaoyang, the Beijing district with the most cases, there were 18 people in line, many of them apparently on the way home from work. Two medical workers in blue full-body protective suits took oral samples at two well-separated tables.
Two other workers, in white full-body hazardous-material suits, checked identity cards. Another 11 guards and other assistants stood nearby, wearing disposable blue hospital gowns over their clothing. The line moved quickly and the tests were free.
Richard Reithinger, vice president for global health at Research Triangle Institute, a nonprofit research group in North Carolina, said that the scale of China’s testing program was impressive but that some of the resources might be better used to expand vaccination. China still lags well behind Western countries in the proportion of older residents in particular who have been vaccinated.
Beijing has now had 138 cases since last Friday scattered across half of its 16 districts. Three dozen of those cases were linked to a single junior high school in southeastern Beijing.
But most Beijing residents can still move freely around the capital. Residents of inland industrial cities are being treated much less gently.
Yiwu, a city of nearly two million in central China that is a trading and manufacturing center for everything from plastic toys to American election campaign merchandise, ordered on Wednesday that no residents could leave their apartment complexes until further notice after just three infections were found there. Baotou, a steel and rare earth metals hub of nearly three million people in the Chinese region of Inner Mongolia, locked down on Monday evening after just two cases were found, and subsequently detected one more case.
The CSI 300 Index of large companies’ share prices on the Shanghai and Shenzhen stock markets rose 2.9 percent on Wednesday as investors appeared to conclude that the worst of the current outbreak might be past. The index dropped 4.9 percent on Monday amid alarm at the detection of dozens of infections in Beijing over the weekend.
Taking a mandatory nucleic acid test every other day is not the biggest nuisance from the continuing campaign against the coronavirus, Beijing residents said in interviews on Wednesday. Regular P.C.R. testing has already been a fact of life for many.
Zhou Yunhong, a pork butcher in north-central Beijing, said that she had been taking a mandatory test every day since February because of a government requirement on anyone working with chilled food.
“I feel it’s good — testing is responsible for our customers,” she said.
The biggest irritation cited by many Beijing residents lies in the stringent rules preventing them from visiting family members in other towns or from taking vacations, including during the national May Day holiday that starts this weekend.
Beijing has warned residents for months that if they leave the capital, they might not be allowed to return, for fear that they might bring the virus back from other cities. But now, other communities are starting to discourage Beijing residents from coming at all, fearing that they could also be carriers of the coronavirus.
Li Kun, an egg vendor at a covered Beijing market, said that she lived just across the municipal border in Hebei Province. But she had been unable to go home for nearly two weeks to see her daughter, who is in high school and now living alone in their house.
“The loudspeaker in our village shouts, ‘Residents from Beijing cannot enter,’” she said. “I do a P.C.R. test every day, I know I’m fine, but the people in the village don’t know; they are worried.”
Every night she has an online video conversation with her daughter, she said, adding: “I want to go home.”
Li You and Liu Yi contributed research.