I was looking into this myself when I was building out a weather application. I didn't see a way to automatically grab the city codes based on name. The feed is coming through from weather.com so if you are able to capture the city codes from there then you should be able to do a conversion between the city name -> city code -> weather. If I come across something I'll let you know.
Jonathan LeBlanc Senior Software Engineer Yahoo! Developer Network