#!/usr/bin/python # coding=utf-8 # 2010-09-16 move from project cyberknife PASSWORD = 'n122119493' from datetime import date import mechanize from urllib2 import urlopen #from ClientForm import ParseResponse import datetime import hashlib import re import urllib import urllib2 import pdb import math import pprint pp = pprint.PrettyPrinter() br = mechanize.Browser(factory=mechanize.RobustFactory()) br.set_handle_robots(False) def xtrace(R): pdb.set_trace() def remove_space(s): return s.replace(' ','').strip() #print remove_space(' 123 ') def minguo2ce(minguo): pattern = '(\d+)\.([ 0-9]{1,2})\.([ 0-9]{1,2})' s = re.search(pattern, minguo) if s: yy = int(s.group(1))+1911 try: mm = int(s.group(2)) except: mm = 1 try: dd = int(s.group(3)) except: dd = 1 return date( yy, mm , dd ) pattern = '(\d+)/([ 0-9]{1,2})/([ 0-9]{1,2})' s = re.search(pattern, minguo) if s: yy = int(s.group(1))+1911 try: mm = int(s.group(2)) except: mm = 1 try: dd = int(s.group(3)) except: dd = 1 return date( yy, mm , dd ) return #print minguo2ce(' 75.01.25') ########## Old intra system def Default_Dr(REQUEST): if (REQUEST.has_key('ChartNo')) and REQUEST['ChartNo'] != "": values = { 'ChartNo' : REQUEST['ChartNo'] } elif (REQUEST.has_key('Name')) and REQUEST['Name'] != "": values = { 'Name' : REQUEST['Name'].decode('utf_8').encode('big5') } elif (REQUEST.has_key('idcode')) and REQUEST['idcode'] != "": values = { 'idcode' : REQUEST['idcode'] } else: return "" url = 'http://intra.mc.ntu.edu.tw/main/ChartNo/Default_Dr.asp' data = urllib.urlencode(values) req = urllib2.Request(url, data) response = urllib2.urlopen(req) the_page = response.read() the_page = the_page.decode('big5','ignore').encode('utf_8') pattern = ( '(?s)(.*?)(.*?)' + '(.*?)(.*?)' + '(.*?)(.*?)' + '(.*?)(.*?)' + '(.*?)(.*?)' + '(.*?)(.*?)' + '(.*?)(.*?)' + '(.*?)' ) matches = re.findall(pattern, the_page) result = [] for match in matches: r = {} r['name'] = remove_space(match[2]) r['medical_records'] = remove_space(match[4]) r['gender'] = remove_space(match[6]) r['birthday'] = minguo2ce(match[8]) r['address'] = remove_space(match[10]) r['phone'] = remove_space(match[12]) r['id_cards'] = remove_space(match[14]) result.append(r) return result #print Default_Dr({ 'HIS' : '', # 'firstname' : '', # 'MIS' : 'N122119493' }) def percent_encoding(keys, REQUEST): data = {} for key in keys: if REQUEST.__contains__(key): data[key] = REQUEST[key] return urllib.urlencode(data) #print percent_encoding(['HIS','MIS'], # { 'HIS' : '3009684', # 'firstname' : '', # 'MIS' : 'N122119493' }) def CheckUser(): br.open("http://intra.mc.ntu.edu.tw/CheckUser_Ehospital.asp?myurl=default_Ehospital.asp") br.select_form(name="form1") br["uid"] = 'dtsurg08' br["pwd"] = 'x' response = br.submit() # submit current form return response.read() def chinese2date(chinese): pattern = '(\d+)(\D+)(\d{1,2})(\D+)(\d{1,2})' s = re.search(pattern, chinese) if s: yy = int(s.group(1)) mm = int(s.group(3)) dd = int(s.group(5)) return date( yy, mm , dd ) return def oncrt_query(ChartNo): url = "http://intra.mc.ntu.edu.tw/DigReport/ONC_RT/oncrt_query.asp" response = br.open(url) if response.read().decode('big5','ignore').encode('utf_8').find('閒置時間超過六十分鐘'): CheckUser() response = br.open(url) br.select_form(name="FrontPage_Form1") br["ChartNo"] = str(ChartNo) response = br.submit() body = response.read().decode('big5','ignore').encode('utf_8') htmlcomments = re.compile('\') body = htmlcomments.sub('', body) # print body # body = body[body.find('←テᄄ¦ᄑヘ'):] pattern = ( '(?s)(\s*?)' +'(.*?)(\s*?)' +'(.*?)(\s*?)' +'(.*?)(\s*?)' +'(.*?)(\s*?)' +'(.*?)(\s*?)' +'(.*?)(\s*?)' +'(.*?)(\s*?)' +'(.*?)(\s*?)' +'(.*?)' ) matches = re.findall(pattern, body) result = [] for match in matches: r = {} r['site'] = remove_space(match[1]) r['way'] = remove_space(match[3]) r['radiation_energy'] = remove_space(match[5]) r['number_of_treatment'] = remove_space(match[7]) r['total_dose'] = remove_space(match[9]) r['start_date'] = chinese2date(match[11]) r['end_date'] = chinese2date(match[13]) r['the_number_of_treatment'] = remove_space(match[15]) r['remarks'] = remove_space(match[17]) result.append(r) return result def op_note_case(ChartNo): url = "http://intra.mc.ntu.edu.tw/DigReport/OpNote/case.asp" response = br.open(url) if response.read().decode('big5','ignore').encode('utf_8').find('閒置時間超過六十分鐘'): CheckUser() response = br.open(url) br.select_form(name="FrontPage_Form1") br["ChartNo"] = str(ChartNo) response = br.submit() body = response.read().decode('big5','ignore').encode('utf_8') htmlcomments = re.compile('\') body = htmlcomments.sub('', body) # print body # body = body[body.find('←テᄄ¦ᄑヘ'):] pattern = ( '(?s)(\s*?)' +'([^\n\r]*?)(\s*?)' +'(\s*?)' +'(\s*?)' +'([^\n\r]*?)(\s*?)' +'(\s*?)' +'(\s*?)' +'([^\n\r]*?)(\s*?)' +'' ) matches = re.findall(pattern, body) result = [] for match in matches: r = {} r['surgery_date_time'] = minguo2ce(match[2]) r['division'] = remove_space(match[6]) r['name_surgery'] = remove_space(match[10]) r['surgeon'] = remove_space(match[14]) result.append(r) return result def path_exam(ChartNo): url = "http://intra.mc.ntu.edu.tw/DigReport/Lab/PathExam.asp" response = br.open(url) if response.read().decode('big5','ignore').encode('utf_8').find('閒置時間超過六十分鐘'): CheckUser() response = br.open(url) br.select_form(name="FrontPage_Form1") br["ChartNo"] = str(ChartNo) response = br.submit() body = response.read().decode('big5','ignore').encode('utf_8') htmlcomments = re.compile('\') body = htmlcomments.sub('', body) # print body # body = body[body.find('←テᄄ¦ᄑヘ'):] ''' S0900742 HMC b 098/01/08 098/01/09 ''' pattern = '''\ (.*?)(\s*?)\ (.*?)(\s*?)\ (.*?)(\s*?)\ (.*?)(\s*?)\ (.*?)(\s*?)\ (.*?)\ ''' matches = re.findall(pattern, body) result = [] for match in matches: # print match r = {} r['path_code'] = remove_space(match[1]) r['specimen_code'] = remove_space(match[6]) r['specimen_get_date'] = minguo2ce(match[7]) r['report_date'] = minguo2ce(match[8]) r['division'] = remove_space(match[15]) r['bed'] = remove_space(match[17]) purl = 'http://intra.mc.ntu.edu.tw/DigReport/Lab/PathReport.asp?PathCode=%s' % r['path_code'] # print purl presponse = br.open(purl) pbody = presponse.read().decode('big5','ignore').encode('utf_8') pbody = htmlcomments.sub('', pbody) ''' Liver, biopsy, hepatocellular carcinoma
''' ppattern = '(.*?)(
|
)' pmatches = re.findall(ppattern, pbody, re.DOTALL) # print pmatches report = [] for pmatch in pmatches: report.append(remove_space(pmatch[0])) # print report r['report'] = ','.join(report) result.append(r) return result def XrayExam(ChartNo): url = "http://intra.mc.ntu.edu.tw/DigReport/Xray/XrayExam.asp" url = 'http://portal.ntuh.gov.tw/DigReport/Xray/XrayExam.asp' response = br.open(url) if response.read().decode('big5','ignore').encode('utf_8').find('閒置時間超過六十分鐘'): CheckUser() response = br.open(url) body = {} br.select_form(name="FrontPage_Form1") br["ChartNo"] = str(ChartNo) br["durnum"] = ['12'] br["reptype"] = ['CT'] br["dattype"] = ['Y'] response = br.submit() body['CT'] = response.read().decode('big5','ignore').encode('utf_8') br.select_form(name="FrontPage_Form1") br["ChartNo"] = str(ChartNo) br["durnum"] = ['12'] br["reptype"] = ['MRI'] br["dattype"] = ['Y'] response = br.submit() body['MRI'] = response.read().decode('big5','ignore').encode('utf_8') # pattern="Pelvis: for THR" pattern="(.*?)" # pattern="Ximage/XrayReport.asp?reportseqno=(.*?)" pattern = pattern.replace("'", "\\'") pattern = pattern.replace('&', '\\&') results = [] for m in ['CT', 'MRI']: matches = re.findall(pattern, body[m]) for match in matches: r = {} r['reportseqno'] = remove_space(match[0]) r['ChartNo'] = remove_space(match[1]) r['ChineseName'] = remove_space(match[2]) r['Sex'] = remove_space(match[3]) r['Birthday'] = remove_space(match[4]) r['ExamDate'] = remove_space(match[5]) r['accessno'] = remove_space(match[6]) r['ReferNo'] = remove_space(match[7]) r['status'] = remove_space(match[8]) r['LinkOrderName'] = remove_space(match[9]) r['Modality'] = m results.append(r) pp.pprint(urllib2.unquote(match[0])) # pp.pprint(results) return results ########################################New portal systemn def Login(): br.open("http://portal.ntuhrs.ntuh.gov.tw/General/Login.aspx") br.select_form(name="Form1") # br["rdblQuickMenu"] = ['O'] br["txtUserID"] = '004552' br["txtPass"] = hashlib.md5(PASSWORD).hexdigest() # print br.possible_items("rdblQuickMenu") # print br.form response = br.submit() # submit current form pattern = "http://hisaw.ntuh.gov.tw/WebApplication/Clinics/OpenClinics.aspx\?SESSION=(\w*)" string = str(response.read()) # print string matches = re.findall(pattern, string) return matches[0] def HeightWeight(PersonID): SESSION = Login() url = "http://ihisaw.ntuh.gov.tw/WebApplication/OtherIndependentProj/PatientBasicInfoEdit/QueryHeightWeightByPersonID.aspx?SESSION=%s&PersonID=%s" % (SESSION,PersonID) response = br.open(url) body = response.read() ''' 171
75 ''' pattern = '''\ (.*?)(\s*?)\ (\s*?)\ (.*?)(\s*?)\ (\s*?)\ (.*?)\ ''' matches = re.findall(pattern, body) # print matches[0] if matches: h = matches[0][0] w = matches[0][6] else: h = 0 w = 0 try: bsa = math.sqrt(float(h) * float(w) / 3600) #Mosteller formula except: bsa = 0 return {'Height': h, 'Weight': w, 'BSA': bsa} def ReportResult(PersonID): SESSION = Login() url = "http://ihisaw.ntuh.gov.tw/WebApplication/OtherIndependentProj/PatientBasicInfoEdit/ReportResultQuery.aspx?SESSION=%s&PersonID=%s" % (SESSION,PersonID) response = br.open(url) br.select_form(name="Form1") response = br.submit() # submit current form body = response.read() print body return response = urlopen(url) forms = ParseResponse(response, backwards_compat=False) form = forms[0] print form form.set_all_readonly(False) form["__EVENTTARGET"] = "LinkbuttonRadReport" # form.click() returns a urllib2.Request object # (see HTMLForm.click.__doc__ if you don't have urllib2) print urlopen(form.click()).read() def icd_query(ChartNo): Login() br.select_form(name="Form1") br["NTUHWeb1:QueryPersonIDByChartNo2:txbChartNoInput"] = str(ChartNo) br["NTUHWeb1:QueryPersonIDByChartNo2:AutoShowRecord"] = True response = br.submit() # submit current form return response.read() ################## os.getcwd()############## def get_path(): import os,sys return os.path.realpath(os.path.dirname(sys.argv[0])) ############################### vs = {} def unf_byDisDate(deptcode, StartDate, EndDate): import csv reader = csv.reader(open(get_path()+"/vs.csv", "rb")) for row in reader: # print row[1], row[0] vs[row[1]]=row[0] url = "http://intra.mc.ntu.edu.tw/main/Discharge/unf_byDisDate.asp" response = br.open(url) br.select_form(nr=0) br["deptcode"] = [deptcode] br["StartDate"] = StartDate br["EndDate"] = EndDate response = br.submit() body = response.read().decode('big5','ignore').encode('utf_8') pattern = """ \s* (.*?) (.*?) (.*?) (.*?)

(.*?) (.*?) (.*?) (.*?) (.*?) (.*?) (.*?) (.*?) """ pattern = pattern.replace('"', '\\"') pattern = pattern.replace('\n', '\\s*') matches = re.findall(pattern, body) result = [] for match in matches: r = {} r['no'] = remove_space(match[0]) r['doctor_code'] = remove_space(match[1]) r['doctor_name'] = remove_space(match[2]) r['discharge_date'] = remove_space(match[3]) r['patients_name'] = remove_space(match[4]) r['medical_record_number'] = remove_space(match[5]) r['account'] = remove_space(match[6]) r['admission_date'] = remove_space(match[7]) r['hospital_ bed'] = remove_space(match[8]) r['category'] = remove_space(match[9]) r['dr'] = remove_space(match[10]) r['resident'] = remove_space(match[11]) if vs.has_key(r['dr']): r['division'] = vs[r['dr']] else: r['division'] = 'Others' result.append(r) return result def formatDate(sDate): dScrap = sDate iDay = dScrap.day iMon = dScrap.month iYea = dScrap.year sDay = str(iDay) sMon = str(iMon) sYea = str(iYea - 1911) if len(sDay) == 1: sDay = "0" + sDay if len(sMon) == 1: sMon = "0" + sMon if len(sYea) == 2: sYea = "0" + sYea; sScrap = sYea + sMon + sDay; return sScrap; def unf_sort(StartDay, EndDay): StartDate = datetime.date.today() + datetime.timedelta(days=StartDay) EndDate = datetime.date.today() + datetime.timedelta(days=EndDay) result = unf_byDisDate('SURG', formatDate(StartDate), formatDate(EndDate)) dr = [] resident = [] division = [] for r in result: dr.append(r['dr']) resident.append(r['resident']) division.append(r['division']) # The count is doubled, so we div it by 2 dr_freq = [(a, dr.count(a)/2) for a in set(dr)] dr_sort = sorted(dr_freq, key=lambda x: -x[1]) resident_freq = [(a, resident.count(a)/2) for a in set(resident)] resident_sort = sorted(resident_freq, key=lambda x: -x[1]) division_freq = [(a, division.count(a)/2) for a in set(division)] division_sort = sorted(division_freq, key=lambda x: -x[1]) # print "\n¦ᄌᄏ₩ᄇᄏ←ニᆱ¥ᄌᆱ,¦ᄏᄑ₩ユᄌ" # for dr in dr_sort: # print "%s,%s" % dr # # print "\n¦ᄑマ←ルᄁ←ニᆱ¥ᄌᆱ,¦ᄏᄑ₩ユᄌ" # for resident in resident_sort: # print "%s,%s" % resident return {'dr': dr_sort, 'resident': resident_sort, 'division': division_sort, } def PACSImageShowList(PersonID, SESSION = Login()): ''' Show list of PACS Image ''' # url = "http://ihisaw.ntuh.gov.tw/WebApplication/OtherIndependentProj/PatientBasicInfoEdit/PACSImageShowList.aspx?SESSION=%s&PatClass=I&AccountIDSE=10T01921636&PersonID=%s&Hosp=T0&Seed=20100915175850&EMRPop=Y" % (SESSION,PersonID) url = "http://ihisaw.ntuh.gov.tw/WebApplication/OtherIndependentProj/PatientBasicInfoEdit/PACSImageShowList.aspx?SESSION=%s&PatClass=I&PersonID=%s&Hosp=T0&EMRPop=Y" % (SESSION,PersonID) # print url response = br.open(url) body = response.read() #5554778 # #T0100881014 # # #20100907 # #Spine:Thoracolumbar AP, LAT. # #DX # #￯﾿ᆬ￯ᄒᄋ￯ᄒᄇ￯﾿ᄃ￯ᄒᄁ￯ᄒᄎ￯﾿ᄄ￯ᄒᆰ￯ᄒヘ pattern=""" (.*?) (.*?) (.*?) (.*?) (.*?) (.*?) """ pattern = pattern.replace('"', '\\"') pattern = pattern.replace('\n', '\\s*') matches = re.findall(pattern, body) results = [] for match in matches: r = {} r['PatChartNo'] = remove_space(match[1]) r['RequestSheetNo'] = remove_space(match[3]) r['ExamDate'] = remove_space(match[5]) r['LinkOrderName'] = remove_space(match[7]) r['Modality'] = remove_space(match[9]) r['VerifiedStateString'] = remove_space(match[11]) results.append(r) return results #def PatientMedicalRecordListQuery(PersonID, SESSION = Login()): def PatientMedicalRecordListQuery(Chart, SESSION = Login()): ''' Show hospital visit ''' # print PersonID # print Chart url = "http://ihisaw.ntuh.gov.tw/WebApplication/OtherIndependentProj/PatientBasicInfoEdit/PatientMedicalRecordListQuery.aspx?QueryBySelf=N&SESSION=%s" % SESSION br.open(url) br.select_form(name="Form1") # br["NTUHWeb1$PersonIDInputTextBox"] = PersonID br["NTUHWeb1$ChartInputTextBox"] = Chart response = br.submit() body = response.read() result = {} #已死亡? pattern = '(.*?)\\((.*?)\\)(.*?)' matches = re.findall(pattern, body) try: match = matches[0] search = re.search('..../../..', match[2]) result['Dead'] = datetime.datetime.strptime(search.group(0),'%Y/%m/%d') except: result['Dead'] = None # match = matches[0] # if match[2].find('已死亡') != -1: # search = re.search('..../../..', match[2]) # result['Dead'] = search.group(0) # else: # result['Dead'] = None # 住 pattern =''' (.*?) .*? (.*?) .*? (.*?) .*? (.*?) .*? (.*?) .*? (.*?) .*? (.*?) .*? (.*?) .*? (.*?) .*? (.*?) ''' pattern = pattern.replace('"', '\\"') pattern = pattern.replace('\n', '\\s*?') matches = re.findall(pattern, body) In = [] for match in matches: r = {} r['HospName'] = remove_space(match[0]) r['DeptName'] = remove_space(match[1]) r['InDate'] = datetime.datetime.strptime(remove_space(match[2]),'%Y/%m/%d') # r['OutDate'] = datetime.datetime.strptime(remove_space(match[3]),'%Y/%m/%d') try: r['OutDate'] = datetime.datetime.strptime(remove_space(match[3]),'%Y/%m/%d') except: r['OutDate'] = None r['WardName'] = remove_space(match[4]) r['RoomName'] = remove_space(match[5]) r['BedName'] = remove_space(match[6]) r['MainDrName'] = remove_space(match[7]) r['MainDiagnosisName'] = remove_space(match[8]) r['StatusName'] = remove_space(match[9]) In.append(r) result['In'] = In # 急 pattern =''' (.*?) .*? (.*?) .*? (.*?) .*? (.*?) .*? (.*?) .*? (.*?) .*? (.*?) .*? (.*?) ''' pattern = pattern.replace('"', '\\"') pattern = pattern.replace('\n', '\\s*?') matches = re.findall(pattern, body) Emer = [] for match in matches: r = {} r['HospName'] = remove_space(match[0]) r['DeptName'] = remove_space(match[1]) r['ComeClinicDate'] = datetime.datetime.strptime(remove_space(match[2]),'%Y/%m/%d') try: r['DischargeDate'] = datetime.datetime.strptime(remove_space(match[3]),'%Y/%m/%d') except: r['DischargeDate'] = None r['MainDrName'] = remove_space(match[4]) r['MainDiagnosisName'] = remove_space(match[5]) r['StatusName'] = remove_space(match[6]) r['TempBedID'] = remove_space(match[7]) Emer.append(r) result['Emer'] = Emer # 門 pattern =''' (.*?) .*? (.*?) .*? (.*?) .*? (.*?) .*? (.*?) .*? (.*?) .*? (.*?) ''' pattern = pattern.replace('"', '\\"') pattern = pattern.replace('\n', '\\s*?') matches = re.findall(pattern, body) OutPat = [] for match in matches: r = {} r['HospName'] = remove_space(match[0]) r['DeptName'] = remove_space(match[1]) r['ComeClinicDate'] = datetime.datetime.strptime(remove_space(match[2]),'%Y/%m/%d') r['SpecialCureName'] = remove_space(match[3]) r['MainDrName'] = remove_space(match[4]) r['MainDiagnosisName'] = remove_space(match[5]) r['AccountStatusName'] = remove_space(match[6]) OutPat.append(r) result['OutPat'] = OutPat return result def doPostBack(form, eventTarget, eventArgument): #Creates a new __EVENTTARGET control and adds the value specified #.NET doesn't generate this in mechanize for some reason -- suspect maybe is #normally generated by javascript or some useragent thing? form.new_control('hidden','__EVENTTARGET',attrs = dict(name='__EVENTTARGET')) form.new_control('hidden','__EVENTARGUMENT',attrs = dict(name='__EVENTARGUMENT')) form.set_all_readonly(False) form["__EVENTTARGET"] = eventTarget form["__EVENTARGUMENT"] = eventArgument def operationnotelist(Chart, SESSION = Login()): url = "http://ihisaw.ntuh.gov.tw/WebApplication/OtherIndependentProj/PatientBasicInfoEdit/PatientMedicalRecordListQuery.aspx?QueryBySelf=N&SESSION=%s" % SESSION br.open(url) br.select_form(name="Form1") # br["NTUHWeb1$PersonIDInputTextBox"] = PersonID br["NTUHWeb1$ChartInputTextBox"] = Chart response = br.submit('NTUHWeb1$ButtonQuery') br.select_form(name="Form1") # request = br.click("NTUHWeb1$PatAccountListRecord1$ShowOperationList") # response = mechanize.urlopen(request) response = br.submit("NTUHWeb1$PatAccountListRecord1$ShowOperationList") '''

''' # print response.read() # return body = response.read() pattern = 'name="KeyCodeList" value=(.*?)>' matches=re.findall(pattern, body) # print matches[0] # print KeyCodeList, KeyNameList # br.select_form('operationnotelist') # response = br.submit() return (matches[0][0], matches[0][1]) def ShowOperationNote(KeyCodeList, KeyNameList, SESSION=Login()): url = 'http://ihisaw.ntuh.gov.tw/WebApplication/OtherIndependentProj/PatientBasicInfoEdit/SimpleInfoShowUsingPlaceHolder.aspx?SESSION=%s' % SESSION data = { 'KeyCodeList': KeyCodeList, 'KeyNameList': KeyNameList, 'Func' : 'OPNoteList', } response = br.open(url, urllib.urlencode(data)) body = response.read() pattern ='(
.*?
)\\s*?' matches=re.findall(pattern, body, re.DOTALL) return matches[0] def dischargenotelist(Chart, SESSION = Login()): url = "http://ihisaw.ntuh.gov.tw/WebApplication/OtherIndependentProj/PatientBasicInfoEdit/PatientMedicalRecordListQuery.aspx?QueryBySelf=N&SESSION=%s" % SESSION br.open(url) br.select_form(name="Form1") br["NTUHWeb1$ChartInputTextBox"] = Chart response = br.submit('NTUHWeb1$ButtonQuery') Notes = re.findall('NTUHWeb1\$.*?ShowDischargeNote', response.read()) # print Notes '''
''' pattern = 'name="KeyCodeList" value=(.*?)>' key = [] for Note in Notes: # print Note br.select_form(name="Form1") response = br.submit(Note) body = response.read() matches=re.findall(pattern, body) for match in matches: # print match key.append(match) return key def ShowDischargeNote(KeyCodeList, KeyNameList, AccountIDSE, SESSION=Login()): url = 'http://ihisaw.ntuh.gov.tw/WebApplication/OtherIndependentProj/PatientBasicInfoEdit/SimpleInfoShowUsingPlaceHolder.aspx?SESSION=%s' % SESSION data = { 'KeyCodeList': KeyCodeList, 'KeyNameList': KeyNameList, 'AccountIDSE': AccountIDSE, 'Func' : 'DischargeSummary', } response = br.open(url, urllib.urlencode(data)) body = response.read() pattern ='(
.*?
)\\s*?' matches=re.findall(pattern, body, re.DOTALL) return matches[0] if __name__ == "__main__": #PatientMedicalRecordListQuery('A101116124') #已死亡 #PatientMedicalRecordListQuery('R100260467') #PatientMedicalRecordListQuery('L200772263') #已死亡 #pp.pprint(PatientMedicalRecordListQuery('4582056')) XrayExam('5621920') pass