Exemplo n.º 1
0
    def __init__(self, loginData):

        self.reservationUrl = "http://concierge.apple.com/reservation/"
        self.authUrl = "https://idmsa.apple.com/IDMSWebAuth/authenticate"

        self.loginData = loginData
        GeniusbarPage._init_headers()
Exemplo n.º 2
0
 def get_geniusbar_page(self, prePage):
     headers = GeniusbarPage.headers
     headers['Referer'] = prePage.get_url()
     headers["Host"] = 'concierge.apple.com'
     geniusbarPage = GeniusbarPage(GeniusbarPage.get_geniusbar_url(),
                                   headers=headers)
     return geniusbarPage
Exemplo n.º 3
0
    def __init__(self, loginData):

        self.reservationUrl = "http://concierge.apple.com/reservation/"
        self.authUrl = "https://idmsa.apple.com/IDMSWebAuth/authenticate"

        self.loginData = loginData
        GeniusbarPage._init_headers()
Exemplo n.º 4
0
 def initUrls(self):
     self.reservationUrl = "http://concierge.apple.com/reservation/"
     self.authUrl = "https://idmsa.apple.com/IDMSWebAuth/authenticate"
     self.govUrlFormat = "https://concierge.apple.com/geniusbar/%s/governmentID"
     self.timeslotFormat = "http://concierge.apple.com/geniusbar/%s/timeslots"
     # http://concierge.apple.com/geniusbar/R448/reservationConfirmation
     self.reservConfirmFormat = 'http://concierge.apple.com/geniusbar/%s/reservationConfirmation'
     self.challengeUrlFormat = 'https://concierge.apple.com/geniusbar/%s/smschallenge'
     GeniusbarPage._init_headers()
Exemplo n.º 5
0
 def initUrls(self):
     self.reservationUrl = "http://concierge.apple.com/reservation/"
     self.authUrl = "https://idmsa.apple.com/IDMSWebAuth/authenticate"
     self.govUrlFormat = "https://concierge.apple.com/geniusbar/%s/governmentID"
     self.timeslotFormat = "http://concierge.apple.com/geniusbar/%s/timeslots"
     # http://concierge.apple.com/geniusbar/R448/reservationConfirmation
     self.reservConfirmFormat = 'http://concierge.apple.com/geniusbar/%s/reservationConfirmation'
     self.challengeUrlFormat = 'https://concierge.apple.com/geniusbar/%s/smschallenge'
     GeniusbarPage._init_headers()
Exemplo n.º 6
0
    def post_geniusbar_page(self, prePage):

        postData = {}
        postData["_formToken"] = prePage.get_formtoken_value()
        postData['supportOffered'] = 'true'
        headers = GeniusbarPage.headers
        headers['Referer'] = prePage.get_url()
        geniusbarPage = GeniusbarPage(GeniusbarPage.get_geniusbar_url(),
                                      data=urllib.urlencode(postData),
                                      headers=headers)
        return geniusbarPage
Exemplo n.º 7
0
 def Get_suppport_url(self, storeUrl):
     debug.debug('get storeurl')
     page = GeniusbarPage(storeUrl)
     attrs = {'class': "nav hero-nav selfclear"}
     page_soup = page.get_soup()
     navtag = page_soup.find('nav', attrs=attrs)
     hrefs = navtag.findAll('a')
     support_url = None
     for href in hrefs:
         target = href.find('img', {'alt': 'Genius Bar'})
         if target:
             support_url = href.get('href')
             break
     return support_url
Exemplo n.º 8
0
 def Get_suppport_url(self, storeUrl):
     debug.debug('get storeurl')
     page = GeniusbarPage(storeUrl)
     attrs = {'class': "nav hero-nav selfclear"}
     page_soup = page.get_soup()
     navtag = page_soup.find('nav', attrs=attrs)
     hrefs = navtag.findAll('a')
     support_url = None
     for href in hrefs:
         target = href.find('img', {'alt': 'Genius Bar'})
         if target:
             support_url = href.get('href')
             break
     return support_url
Exemplo n.º 9
0
 def Get_workshops_url(self, storeUrl):
     page = GeniusbarPage(storeUrl)
     data = page.get_data()
     Writefile('debug/workshops.html', data)
     attrs = {'class': "nav hero-nav selfclear"}
     page_soup = page.get_soup()
     navtag = page_soup.find('nav', attrs=attrs)
     hrefs = navtag.findAll('a')
     url = None
     for href in hrefs:
         target = href.find('img', {'alt': 'Workshops'})
         if target:
             url = href.get('href')
             break
     return url
Exemplo n.º 10
0
 def post_smschallenge(self, prePage):
     '''
     "serviceType_iPhone"
     "serviceType_iPad"
     "serviceType_iPod"
     "serviceType_Mac"
     '''
     reservType = self.loginData['reservType']
     postData = prePage.build_smschallenge_post_data(reservType)
     headers = GeniusbarPage.headers
     headers['Referer'] = GeniusbarPage.get_geniusbar_url()
     smschallenge = GeniusbarPage(GeniusbarPage.get_geniusbar_url(),
                                  urllib.urlencode(postData),
                                  headers=GeniusbarPage.headers)
     return smschallenge
Exemplo n.º 11
0
 def post_smschallenge(self, prePage):
     '''
     "serviceType_iPhone"
     "serviceType_iPad"
     "serviceType_iPod"
     "serviceType_Mac"
     '''
     reservType = self.loginData['reservType']
     postData = prePage.build_smschallenge_post_data(reservType)
     headers = GeniusbarPage.headers
     headers['Referer'] = GeniusbarPage.get_geniusbar_url()
     smschallenge = GeniusbarPage(GeniusbarPage.get_geniusbar_url(),
                                  urllib.urlencode(postData),
                                  headers=GeniusbarPage.headers)
     return smschallenge
Exemplo n.º 12
0
 def Get_workshops_url(self, storeUrl):
     page = GeniusbarPage(storeUrl)
     data = page.get_data()
     Writefile('debug/workshops.html', data)
     attrs = {'class': "nav hero-nav selfclear"}
     page_soup = page.get_soup()
     navtag = page_soup.find('nav', attrs=attrs)
     hrefs = navtag.findAll('a')
     url = None
     for href in hrefs:
         target = href.find('img', {'alt': 'Workshops'})
         if target:
             url = href.get('href')
             break
     return url
Exemplo n.º 13
0
 def get_geniusbar_page(self, prePage):
     headers = GeniusbarPage.headers
     headers['Referer'] = prePage.get_url()
     headers["Host"] = 'concierge.apple.com'
     geniusbarPage = GeniusbarPage(GeniusbarPage.get_geniusbar_url(),
                                   headers=headers)
     return geniusbarPage
Exemplo n.º 14
0
 def post_reserv_page(self, prePage, rultype='TECHSUPPORT'):
     postData = {}
     postData['_formToken'] = prePage.get_formtoken_value()
     attrs = {'selected': 'selected'}
     postData['storeNumber'] = prePage.get_tag_value('option', attrs=attrs)
     GeniusbarPage.storeNumber = postData['storeNumber']
     postData['store'] = GeniusbarPage.storeNumber
     postData['ruleType'] = rultype
     page = GeniusbarPage(self.reservationUrl, urllib.urlencode(postData))
     return page
Exemplo n.º 15
0
    def post_geniusbar_page(self, prePage):

        postData = {}
        postData["_formToken"] = prePage.get_formtoken_value()
        postData['supportOffered'] = 'true'
        headers = GeniusbarPage.headers
        headers['Referer'] = prePage.get_url()
        geniusbarPage = GeniusbarPage(GeniusbarPage.get_geniusbar_url(),
                                      data=urllib.urlencode(postData),
                                      headers=headers)
        return geniusbarPage
Exemplo n.º 16
0
 def post_governmenid(self, url, prepage):
     postData = prepage.build_governmentid_post_data()
     postData["_formToken"] = prepage.get_formtoken_value()
     postData['governmentID'] = self.loginData['governmentID']
     postData['governmentIDType'] = self.loginData['governmentIDType']
     #'CN.PRCID'
     if not postData['clientTimezone']:
         postData['clientTimezone'] = 'Asia/Shanghai'
     headers = GeniusbarPage.headers
     headers['Referer'] = prepage.get_url()
     gnPage = GeniusbarPage(url, urllib.urlencode(postData), headers)
     return gnPage
Exemplo n.º 17
0
    def post_anth_page(self, prePage):

        postData = prePage.build_auth_post_data()
        # 'Qq654123'
        postData['accountPassword'] = self.loginData['accountPassword']
        postData['appleId'] = self.loginData['appleId']
        # '*****@*****.**'
        headers = GeniusbarPage.headers
        headers['Host'] = "concierge.apple.com"
        headers['Referer'] = prePage.get_url()
        authPage = GeniusbarPage(self.authUrl,
                                 data=urllib.urlencode(postData),
                                 headers=headers)
        return authPage
Exemplo n.º 18
0
    def Jump_workshops_page(self, enterUrl, taskStatus=None):
        self.initUrls()
        self.taskStatus = taskStatus
        print('workshops %s' % enterUrl)
        wkshpg = GeniusbarPage(enterUrl)
        print(wkshpg)
        #self.update_progress(20)
        #Writefile('debug/wkspage.html', wkshpg.get_data())
        self.update_progress(30)
        reserpage = self.post_reserv_page(wkshpg, 'WORKSHOP')
        #Writefile('debug/geniuspage.html', reserpage.get_data())
        workshopsurl = 'http://concierge.apple.com/workshops/' + GeniusbarPage.storeNumber
        self.update_progress(60)

        #genpage = self.get_geniusbar_page(wkshpg)
        postData = {}
        postData['id'] = '5756055972603593735'
        postData['_formToken'] = reserpage.get_formtoken_value()
        postData['workshopTypeName'] = 'CUSTOM_WORKSHOP'
        timeslotpage = GeniusbarPage(workshopsurl,
                                     data=urllib.urlencode(postData),
                                     headers=GeniusbarPage.headers)
        self.update_progress(100)
        self.afterReserWorkShops(timeslotpage, taskStatus)
Exemplo n.º 19
0
    def waitingCmd(self, page, taskStatus):
        '''
        waiting the input
        '''
        runtime = 300  # waiting time
        storeUrl = taskStatus['storeUrl']
        debug.debug(storeUrl)

        while runtime > 0:
            taskCmd = taskStatus['taskCmd']
            if taskCmd == 'refresh':
                debug.debug('refresh cmd %s' % taskStatus['appleId'])
                verifycodedata, tSt = page.get_verification_code_pic()
                taskStatus['verifyCodeData'] = verifycodedata
                taskStatus['taskCmd'] = None
                time.sleep(1)
                continue
            if taskCmd == 'submit':
                debug.debug('get submit cmd %s' % taskStatus['appleId'])
                postData = page.build_submit_post_data()
                postData['captchaAnswer'] = taskStatus['captchaAnswer']
                postData['phoneNumber'] = taskStatus['phoneNumber']
                postData['smsCode'] = taskStatus['smsCode']
                postData['clientTimezone'] = taskStatus['clientTimezone']
                # 'Asia/Shanghai'
                submitUrl = self.challengeUrlFormat % GeniusbarPage.storeNumber
                headers = page.headers
                headers['Referer'] = submitUrl
                headers.pop('Accept-Encoding')
                submitpage = GeniusbarPage(submitUrl,
                                           data=urllib.urlencode(postData),
                                           headers=headers)
                data = submitpage.get_data()
                resultfile = 'tmp/%s.htm' % taskStatus['appleId']
                Writefile(resultfile, data)

                attrs = {
                    "class": "error-message on",
                    "id": "error_message_generalError"
                }
                errorMsg = submitpage.get_tag_text('label', attrs=attrs)
                if errorMsg:
                    taskStatus['cmdStatus'] = 'NOK'
                    taskStatus['taskCmd'] = None
                    taskStatus['prompInfo'] = errorMsg
                    page = submitpage
                    debug.error(errorMsg)
                    Writefile('tmp/submiterr.html', page.get_data())
                    continue
                else:
                    # success for submit
                    # get the time slots
                    ret, maxrow = self.buildTimeSlotsTable(submitpage)
                    taskStatus['cmdStatus'] = 'OK'
                    taskStatus['timeSlots'] = (ret, maxrow)
                    taskStatus['taskCmd'] = None
                    page = submitpage
                    continue
            if taskCmd == 'timeslot':
                # post timeslots
                debug.debug('get timeslot cmd %s' % taskStatus['appleId'])
                postData = self.buildPostTimeSlotsData(page)
                postData['clientTimezone'] = taskStatus['clientTimezone']
                postData['id'] = taskStatus['id']
                tlsUrl = self.timeslotFormat % GeniusbarPage.storeNumber
                debug.debug('tls ulr %s' % tlsUrl)
                headers = {}
                headers[
                    'Accept-Language'] = 'zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3'
                headers[
                    'User-Agent'] = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0"
                headers[
                    'Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
                headers["Connection"] = 'keep-alive'
                headers["Host"] = 'concierge.apple.com'
                tlspage = GeniusbarPage(tlsUrl,
                                        data=urllib.urlencode(postData),
                                        headers=headers)
                data = tlspage.get_data()
                Writefile('tmp/posttimeslotsresult.html', data)
                text = self.getConfirmMsg(tlspage)
                taskStatus['prompInfo'] = text.replace(' ', '')
                Writefile('tmp/reserv-%s' % taskStatus['appleId'],
                          taskStatus['prompInfo'])
                taskStatus['taskCmd'] = None
                taskStatus['cmdStatus'] = 'OK'
                break
            if taskCmd == 'end':
                taskStatus['taskCmd'] = None
                break
            #debug.debug('waiting cmd')
            time.sleep(1)
            runtime -= 1
        debug.info('End task %s' % taskStatus['appleId'])
Exemplo n.º 20
0
 def Init_stores_list(self):
     storeListurl = 'http://www.apple.com/cn/retail/storelist/'
     page = GeniusbarPage(storeListurl)
     AppleGeniusBarReservation.stores = page.get_store_list()
     return AppleGeniusBarReservation.stores
Exemplo n.º 21
0
 def Init_stores_list(self):
     storeListurl = 'http://www.apple.com/cn/retail/storelist/'
     page = GeniusbarPage(storeListurl)
     AppleGeniusBarReservation.stores = page.get_store_list()
     return AppleGeniusBarReservation.stores
Exemplo n.º 22
0
 def get_techsupport_page(self, url):
     # debug.debug('GET %s' % url)
     headers = GeniusbarPage.headers
     # print('heaader %s' % headers)
     page = GeniusbarPage(url, headers=headers)
     return page
Exemplo n.º 23
0
    def waitingCmd(self, page, taskStatus):
        '''
        waiting the input
        '''
        runtime = 300  # waiting time
        storeUrl = taskStatus['storeUrl']
        debug.debug(storeUrl)

        while runtime > 0:
            taskCmd = taskStatus['taskCmd']
            if taskCmd == 'refresh':
                debug.debug('refresh cmd %s' % taskStatus['appleId'])
                verifycodedata, tSt = page.get_verification_code_pic()
                taskStatus['verifyCodeData'] = verifycodedata
                taskStatus['taskCmd'] = None
                time.sleep(1)
                continue
            if taskCmd == 'submit':
                debug.debug('get submit cmd %s' % taskStatus['appleId'])
                postData = page.build_submit_post_data()
                postData['captchaAnswer'] = taskStatus['captchaAnswer']
                postData['phoneNumber'] = taskStatus['phoneNumber']
                postData['smsCode'] = taskStatus['smsCode']
                postData['clientTimezone'] = taskStatus['clientTimezone']
                # 'Asia/Shanghai'
                submitUrl = self.challengeUrlFormat % GeniusbarPage.storeNumber
                headers = page.headers
                headers['Referer'] = submitUrl
                headers.pop('Accept-Encoding')
                submitpage = GeniusbarPage(submitUrl,
                                           data=urllib.urlencode(postData),
                                           headers=headers)
                data = submitpage.get_data()
                resultfile = 'tmp/%s.htm' % taskStatus['appleId']
                Writefile(resultfile, data)

                attrs = {"class": "error-message on",
                         "id": "error_message_generalError"}
                errorMsg = submitpage.get_tag_text('label', attrs=attrs)
                if errorMsg:
                    taskStatus['cmdStatus'] = 'NOK'
                    taskStatus['taskCmd'] = None
                    taskStatus['prompInfo'] = errorMsg
                    page = submitpage
                    debug.error(errorMsg)
                    Writefile('tmp/submiterr.html', page.get_data())
                    continue
                else:
                    # success for submit
                    # get the time slots
                    ret, maxrow = self.buildTimeSlotsTable(submitpage)
                    taskStatus['cmdStatus'] = 'OK'
                    taskStatus['timeSlots'] = (ret, maxrow)
                    taskStatus['taskCmd'] = None
                    page = submitpage
                    continue
            if taskCmd == 'timeslot':
                # post timeslots
                debug.debug('get timeslot cmd %s' % taskStatus['appleId'])
                postData = self.buildPostTimeSlotsData(page)
                postData['clientTimezone'] = taskStatus['clientTimezone']
                postData['id'] = taskStatus['id']
                tlsUrl = self.timeslotFormat % GeniusbarPage.storeNumber
                debug.debug('tls ulr %s' % tlsUrl)
                headers = {}
                headers['Accept-Language'] = 'zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3'
                headers['User-Agent'] = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0"
                headers['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
                headers["Connection"] = 'keep-alive'
                headers["Host"] = 'concierge.apple.com'
                tlspage = GeniusbarPage(tlsUrl,
                                        data=urllib.urlencode(postData),
                                        headers=headers)
                data = tlspage.get_data()
                Writefile('tmp/posttimeslotsresult.html', data)
                text = self.getConfirmMsg(tlspage)
                taskStatus['prompInfo'] = text.replace(' ', '')
                Writefile('tmp/reserv-%s' % taskStatus['appleId'],
                          taskStatus['prompInfo'])
                taskStatus['taskCmd'] = None
                taskStatus['cmdStatus'] = 'OK'
                break
            if taskCmd == 'end':
                taskStatus['taskCmd'] = None
                break
            #debug.debug('waiting cmd')
            time.sleep(1)
            runtime -= 1
        debug.info('End task %s' % taskStatus['appleId'])