It's possible to submit your passport to the local People's Republic of China Consulate, pay a fee, and wait a couple of weeks to obtain an L-class Tourist visa for China. Here's another way:

Leave home with your passport. You don't need a visa now. Fly into Macau.

Macau, like Hong Kong, is more or less a free port. You don't need a visa to enter; say you're visiting, in transit, or whatever, and you get a stamp on entry, no charge. I don't know how long it's good for -- perhaps 30 days -- but you won't need it for more than 30 minutes anyway (unless you want to debauch yourself).

Bite the bullet and take a taxicab from the Macau airport to the Barrier Gate. You may well be able to split the cost with others. You can also take a bus, but I don't recommend this for the uninitiated.

The Barrier Gate is the land portal between Macau and Zhuhai; the latter is the city on the mainland side. Macau is on a peninsula on the other side of the Pearl River estuary from Hong Kong. A relatively short -- and well guarded -- land border was created long ago when Macau was given to the Portuguese. Macau now belongs to the PRC, but it is run like an independent country, with its own currency, customs, immigration, and so forth.

The original Barrier Gate can still be seen, though not actually passed through; it is a sort of outdoor museum piece. The new Barrier Gate is a low-slung terminal-looking building, with a duty-free shop on the Macau side. You will pass through Macau exit immigration and customs very quickly, and have a walk of about 100 meters from there to the Barrier Gate. Free-lance porters are available.

When inside the Barrier Gate lobby, you will see a very long row of PRC immigration booths dead ahead. Ignore them. Turn to your left and look for the tiny CITS agency. It looks like a travel agency (which it is, in theory) but its only business is selling visas. The actual PRC government visa office is at the other side of the lobby, but they do not want to see you there. CITS will take your stuff and walk it up to the real visa office.

Hand over your passport and money, fill out the form, give CITS a couple of passport photos (or pay more for them to take) and wait. I've never waited an entire hour for an L-class (tourist) visa. I've never heard of anybody having trouble at this point -- no denials -- and I've done it 4 or 5 times myself.

I seem to remember paying about 100 yuan for this each time, but it may have been more and, like everything else in China, is subject to arbitrary change without notice. In any case, you won't pay more than US$20.

You will get an L visa good for 90 days this way, as opposed to the standard 30. If you do it again (not the first time), you can cook up an obviously transparent story backed by a letter from a "Chinese relative" and, for a few kwai more, get 180 days.

You can also get other types of visas this way, but you may be better off using another method. You can get F visas via the desk of your expensive international hotel in Hong Kong in about a day, depending on what you're willing to pay.

You can also get L visas by yourself in Hong Kong, but it is more expensive and not as fast.