THE Chinese blogosphere has moved on very quickly from the case of Chen Guangcheng. (The blind activist arrived in America on May 19th, more than four weeks after he first took refuge in the American embassy). Mr Chen's case has not disappeared from view entirely. Instead the accusations about the Americans scheming to assist Mr Chen in his escape from house arrest have been folded into a broader debate about foreigners in China. Ever since foreigners arrived in China in large numbers in the 19th century, there has been a tendency either to lionise all that is foreign or to denigrate it, and to treat foreigners themselves either as gods or as barbarians. That dynamic has been very much on display in recent weeks. First, in the divine department, in early May a young language student from America saw an old beggar, bought her some chips and sat down to have a chat with her. Someone snapped a picture, put it on the internet and soon the young man was regarded as a full-blown hero. Cue the soul-searching among Chinese bloggers, wondering helplessly why the Chinese people cannot be more like this foreigner. Around the same time, a good Samaritan from Brazil came to the rescue of a Chinese woman who was being mugged. He was beaten up himself while a Chinese crowd stood watching. This came only months after a Uruguayan woman had saved someone from drowning in Hangzhou's West lake. Both cases stirred up similar hand-wringing about China losing its moral compass, and needing to learn more from foreigners and so on. (One of the reasons the now-purged boss of Chongqing, Bo Xilai, was so popular was for espousing a return to good old-fashioned Maoist morality, a sort of “back to basics” movement for 21st century China.)

Then, just as the nearly 1m foreigners living in China could bear the adulation no longer, along came a lout from Britain to play the barbarian card (pictured above). On May 8th a video was posted on YouKu (and soon after on its foreign equivalent, YouTube) showing a Western man apparently trying to sexually assault a Chinese woman beside a busy street in central Beijing. In the extraordinary footage various Chinese people try to intervene, at least up to the point when the (clearly inebriated) man then passed out in the middle of the road. The anger with which he was being kicked by one Chinese passerby seems to hint at the sense of grievance that has been building up towards foreigners in recent months (or centuries). The same Brit had, it turned out, been spotted (and photographed) sexually harassing young women on the Beijing underground; and photos of that were posted on Sina Weibo. While politically sensitive words, photos and videos are erased from Chinese websites almost immediately, non-political posts such as these are still allowed—even when they are inflammatory. (A few English-language websites make it easy to catch a glimpse of what circulates on the Chinese web.

At almost the same time another video of a Western man behaving badly came to light, this one on a train journey from Shenyang to Beijing. A foul-mouthed Russian puts his feet up on the back of a Chinese woman's seat and proceeds to spew forth a torrent of abuse in Mandarin when she objects. When the train's conductor arrives and sheepishly asks what's going on (kid gloves for barbarians), the dissolute white man foolishly boasts that he is a cellist. That was enough for the online mob to track him down and discover that he is the principal cellist in the Beijing Symphony Orchestra, a Russian called Oleg Vedernikov. He apologised for his behaviour but was subsequently suspended from the orchestra. All of this has played out against a new campaign to crack down on foreigners living in China illegally. Some Chinese bloggers have praised it as a move to kick out “foreign trash”.

But such posturing was as nothing compared to the online tirade that was launched by one of the most visible presenters on China Central Television (CCTV), Yang Rui. Mr Yang is well known as the host of “Dialogue”, a programme on CCTV's main English-language channel in which foreigners are invited to discuss issues of the day. On May 16th Mr Yang used his microblog to trumpet his full support of the new campaign against illegal foreigners, saying that the public-security ministry “must clean out the foreign trash, catch foreign lowlifes and protect innocent girls”. He also urged Chinese people to “learn to recognise the foreign spies who find a Chinese girl to shack up with while they make a living compiling intelligence reports”. He then called the expelled Al Jazeera correspondent Melissa Chan “a bitch” and said that anyone who demonises China should shut up and get lost (to paraphrase politely).

It should be pointed out that most Chinese people are extremely courteous and hospitable to foreigners who come to China. But recent diplomatic spats have bred tensions. The rant may or may not seem extreme if it were coming from your average Zhou—indeed commercial American TV plays host to some pretty xenophobic rants as well—but coming as it does from the highest-profile English-language host on CCTV, it has caused some consternation. Certainly there are plenty of young foreigners drifting through China, as there are in many Asian countries, and they sometimes cause annoyance or worse. But for a leading public figure to act out such xenophobia is a shock. Subsequent messages on Mr Yang's microblog have included barbs for the Philippines and Vietnam over their policies in the South China Sea. One of these ends with the phrase “don't try to mess with us or it'll be no more Mr Nice Guy”.

Three things are noteworthy about the fallout from Mr Yang's rants. First, the extent to which other Chinese microbloggers have pushed back at his apparent xenophobia. The two decades after the Tiananmen Square uprising in 1989 were broadly characterised by growing anti-foreign sentiment. Young Chinese were enjoying their country's increased international influence and starting to see the West, and especially America, as an international bully. (Does anyone in the West even remember NATO's bombing of the Chinese embassy in Belgrade in 1999? Everyone in China does.) In the past couple of years however, debate has become more nuanced as a growing number of younger, increasingly urbanised Chinese people start to distinguish between their opinion of the Communist Party from their pride in their nation. This is a generation that sees Chinese patriotism as being compatible with criticism of the government's policies. (Something that Westerners have yet to master—eg, in the run-up to America's invasion of Iraq, when anti-war protesters were routinely lambasted as “unpatriotic”.) This marks a huge change for China. The dialogue provoked by Mr Yang's comments has contributed to a debate that is fundamentally enlightening, albeit sometimes overheated and nationalistic.

The second point is perhaps farther-reaching, and more worrying. Certainly there is plenty of opposition to the rants of Yang Rui and others like him, but there is also a great deal of support. The fear is that this will grow. On nationalistic issues the general public can become more militant than the government—indeed it often accuses the government of being too soft. At the same time that China is becoming more confident internationally, after 30 years of scorched-earth GDP growth, the Chinese economy is starting to slow. Lower rates of growth seem sure to accentuate brooding social problems. Complaints at home, in turn, might tempt the Chinese government to channel popular anger towards that old bugbear, “outside forces”, to vent these frustrations. In recent years they have been particularly adept at using Japan to this end, but America is another favourite target. The fact that Yang Rui felt that he, a high-profile TV host, couldraise such incendiary topics says much about the prevailing mood in official circles in Beijing.

The third issue highlighted by Mr Yang and his detractors is the huge role that the internet—and especially microblogs—are playing in Chinese discourse, and ultimately in government policy. The Chinese-language internet has already had a crucial effect in creating a more sophisticated, informed and critical public awareness. But it can easily inflame nationalistic tempers too. Because the government's censors are still able to set some limits to web traffic, they retain remarkable power to manipulate popular feeling, for better and for worse.

Bearing in mind the sensitive atmosphere of the moment, perhaps it is amazing that there hasn't been more online anger—for or against Bo Xilai and the princelings, for instance. Or that Chen Guangcheng's departure for America went as smoothly as it did. What is clear is that underneath that smooth, calm surface, people are seething. As if there were not enough for microbloggers to gripe about, the new anti-foreigner spirit adds a dangerous element to the mix. Even Mr Yang himself seemed to recognise this, in a later blog post, when he said that, while it is “important to sweep away all the foreign trash”, Chinese people must “also be cautious of xenophobia and new variations on the Boxer Uprising”. Meanwhile, young Westerners in Chinese cities are urgently making sure their papers are in order.