def get(self): soup = BeautifulSoup( urllib2.urlopen( dptUrl ) ) table = soup.form.find('table', id='Table1') tdlist = table.findAll('td') code = 0; for td in tdlist: name = td.a.text.split('(')[0] # Using split to escape the spcial case dpt = Department() dpt.dptName = name # Removing the @ character dpt.dptCode = code code = code + 1 urlStr1 = 'http://www.tzuchi.com.tw/tchw/opdreg/OpdTimeShow.aspx?Depart=' urlStr2 = '&HospLoc=3' dpt.dptLink = urlStr1 + urllib2.quote(name.encode('utf-8')) + urlStr2 dpt.put() self.response.out.write("Finish for department list ...")