Ejemplo n.º 1
0
 def get_place_data(self) -> [Place]:
     try:
         elements = self.driver.find_elements_by_xpath('//*[@id="content"]/section/div[2]/div/div[2]/div/table/tbody/tr')
         time.sleep(1)
         if elements[0].find_element_by_xpath('./td').text == '등록된 매장이 없습니다.':
             return []
     except:
         print('추가 데이터가 없습니다.')
         return []
     places = []
     num = 1
     for element in elements:
         print(num)
         name = '%s %s' % (self.brand_name, element.find_element_by_xpath('./td[1]/span').text.split('-')[1])
         address = element.find_element_by_xpath('./td[2]/span').text
         telephone = element.find_element_by_xpath('./td[3]/a').text
         latitude, longitude = get_latlng(address.split('(')[0], name)
         if not latitude or not longitude:
             print('[failed] %s\n%s\n%s' % (name, address, telephone))
             continue
         print(latitude, longitude)
         places.append(Place(name=name, address=address, latitude=latitude, longitude=longitude,
                             telephone=telephone, brand=self.get_brand()))
         time.sleep(0.5)
         num += 1
     return places
Ejemplo n.º 2
0
 def get_place_data(self):
     elements = self.driver.find_elements_by_xpath(
         '//*[@id="fboardlist"]/div/table/tbody/tr')
     try:
         if elements[0].find_element_by_class_name('empty_table'):
             print('추가 데이터가 없습니다.')
             return []
     except:
         pass
     places = []
     for element in elements:
         place_name = str(
             element.find_element_by_xpath('./td[2]/div/a/div[2]').text)
         print(place_name)
         name = '%s %s' % (self.brand_name, place_name)
         telephone = element.find_element_by_xpath('./td[5]/div[2]').text
         address = element.find_element_by_xpath('./td[3]/div[2]').text
         working_time = element.find_element_by_xpath('./td[4]/div[2]').text
         description = '영업시간: %s' % working_time
         latitude, longitude = get_latlng(address, name)
         if not latitude or not longitude:
             print('[failed] %s\n%s\n%s\n%s' %
                   (name, description, address, telephone))
             continue
         places.append(
             Place(name=name,
                   address=address,
                   description=description,
                   latitude=latitude,
                   longitude=longitude,
                   telephone=telephone,
                   brand=self.get_brand()))
         time.sleep(0.5)
     return places
Ejemplo n.º 3
0
 def get_place_data(self):
     if self.brand:
         return []  # 첫페이지만 있으니까 추가해두는 임시코드
     try:
         elements = self.driver.find_elements_by_xpath(
             '/html/body/div[2]/div[3]/div/div[2]/div[2]/table/tbody/tr')
     except:
         print('추가 데이터가 없습니다.')
         return []
     places = []
     for element in elements:
         name = '%s %s' % (self.brand_name,
                           element.find_element_by_xpath('./td[2]').text)
         address = element.find_element_by_xpath('./td[3]').text
         telephone = element.find_element_by_xpath('./td[4]').text
         latitude, longitude = get_latlng(address, name)
         if not latitude or not longitude:
             print('[failed] %s\n%s\n%s' % (name, address, telephone))
             continue
         places.append(
             Place(name=name,
                   address=address,
                   latitude=latitude,
                   longitude=longitude,
                   telephone=telephone,
                   brand=self.get_brand()))
         time.sleep(0.5)
     return places
Ejemplo n.º 4
0
 def get_place_data(self) -> [Place]:
     if self.is_last_page:
         return []
     elements = self.driver.find_elements_by_xpath(
         '//*[@id="fboardlist"]/div/div[3]/ul/li')
     time.sleep(1)
     places = []
     num = 1
     for element in elements:
         name = '%s %s' % (self.brand_name,
                           element.find_element_by_xpath('./a/p[1]').text)
         print(name)
         address_and_telephone = element.find_element_by_xpath(
             './a/p[2]').text
         address = address_and_telephone.split('\n')[0]
         telephone = address_and_telephone.split('\n')[1]
         latitude, longitude = get_latlng(
             address.split('(')[0],
             name.split('H')[0])
         if not latitude or not longitude:
             print('[failed] %s\n%s\n%s' % (name, address, telephone))
             continue
         print(latitude, longitude)
         places.append(
             Place(name=name,
                   address=address,
                   latitude=latitude,
                   longitude=longitude,
                   telephone=telephone,
                   brand=self.get_brand()))
         time.sleep(0.5)
         num += 1
     return places
Ejemplo n.º 5
0
 def get_place_data(self):
     try:
         elements = self.driver.find_elements_by_xpath(
             '//*[@id="boardWrap"]/ul/li')
     except:
         print('추가 데이터가 없습니다.')
         return []
     places = []
     for element in elements:
         place_name = str(element.find_element_by_xpath('./p[1]').text)
         print(place_name)
         if place_name.startswith('NEW'):
             place_name = place_name.split('NEW')[1]
         if place_name.endswith('점점'):
             place_name = place_name[:len(place_name) - 1]
         name = '%s %s' % (self.brand_name, place_name)
         telephone = element.find_element_by_xpath('./p[3]').text
         address = element.find_element_by_xpath('./p[2]').text
         latitude, longitude = get_latlng(address, name)
         if not latitude or not longitude:
             print('[failed] %s\n%s\n%s' % (name, address, telephone))
             continue
         places.append(
             Place(name=name,
                   address=address,
                   latitude=latitude,
                   longitude=longitude,
                   telephone=telephone,
                   brand=self.get_brand()))
         time.sleep(0.5)
     return places
Ejemplo n.º 6
0
 def get_place_data(self) -> [Place]:
     try:
         elements = self.driver.find_elements_by_xpath('//*[@id="fboardlist"]/div/table/tbody/tr')
         time.sleep(1)
         if elements[0].find_element_by_xpath('./td').text == '게시물이 없습니다.':
             return []
     except:
         print('추가 데이터가 없습니다.')
         return []
     places = []
     for element in elements:
         name = element.find_element_by_xpath('./td[3]').text
         if '두끼 ' in name:
             name = name.split('두끼 ')[1]
         name = '%s %s' % (self.brand_name, name.split('(')[0])
         address = element.find_element_by_xpath('./td[4]').text
         telephone = element.find_element_by_xpath('./td[5]').text
         latitude, longitude = get_latlng(address.split(',')[0], name)
         print('[%s] %s\n%s (%s, %s)' % (name, telephone, address, latitude, longitude))
         if not latitude or not longitude:
             print('[failed] %s\n%s\n%s' % (name, address, telephone))
             continue
         print(latitude, longitude)
         places.append(Place(name=name, address=address, latitude=latitude, longitude=longitude,
                             telephone=telephone, brand=self.get_brand()))
         time.sleep(0.5)
     return places
Ejemplo n.º 7
0
    def get_place_data(self):
        elements = self.driver.find_elements_by_xpath(
            '//*[@id="sb-list"]/table/tbody/tr')
        if elements[0].find_element_by_xpath('./td').text == '매장이 없습니다.':
            return []

        places = []
        for element in elements:
            place_name = element.find_element_by_xpath('./td[1]').text

            name = '%s %s' % (self.brand_name, place_name)
            address = element.find_element_by_xpath('./td[2]').text
            telephone = element.find_element_by_xpath('./td[3]').text

            latitude, longitude = get_latlng(address, name)
            print('[%s] %s %s (%s,%s)' %
                  (name, address, telephone, latitude, longitude))
            if not latitude or not longitude:
                print('[failed] %s\n%s\n%s' % (name, address, telephone))
                continue
            places.append(
                Place(name=name,
                      address=address,
                      latitude=latitude,
                      longitude=longitude,
                      telephone=telephone,
                      brand=self.get_brand()))
            time.sleep(0.5)
        return places
Ejemplo n.º 8
0
    def get_place_data(self):
        try:
            elements = self.driver.find_elements_by_xpath(
                '//*[@id="addList"]/ul/li')
        except:
            print('추가 데이터가 없습니다.')
            return []
        places = []
        for element in elements:
            place_name = str(
                element.find_element_by_xpath(
                    './div[1]/a/div/p[1]').text).replace('이소 ', '')

            name = '%s %s' % (self.brand_name, place_name)
            print(name)
            address = element.find_element_by_xpath('./div[1]/a/div/p[2]').text
            latitude, longitude = get_latlng(address, name)
            if not latitude or not longitude:
                print('[failed] %s\n%s' % (name, address))
                continue
            telephone = str(
                element.find_element_by_xpath('./div[1]/a/div/p[3]').text)
            telephone = telephone.replace('전화번호 : ', '')
            places.append(
                Place(name=name,
                      address=address,
                      telephone=telephone,
                      latitude=latitude,
                      longitude=longitude,
                      brand=self.get_brand()))
            time.sleep(0.5)
        return places
Ejemplo n.º 9
0
 def get_place_data(self):
     try:
         elements = self.driver.find_elements_by_xpath('//*[@id="wrap"]/div[15]/div[2]/ul/li')
     except:
         return []
     places = []
     for element in elements:
         place_name = str(element.find_element_by_xpath('./a/div[2]/p[1]').text)
         name = '%s %s' % (self.brand_name, place_name)
         try:
             address = element.find_element_by_xpath('./a/div[2]/p[2]').text.split('주소 : ')[1]
         except:
             address = None
         try:
             telephone = element.find_element_by_xpath('./a/div[2]/p[3]').text.split('TEL : ')[1]
         except:
             telephone = None
         print(name)
         latitude, longitude = get_latlng(address, name)
         if not latitude or not longitude:
             print('[failed] %s\n%s\n%s' % (name, address, telephone))
             continue
         places.append(Place(name=name, address=address, latitude=latitude, longitude=longitude,
                             telephone=telephone, brand=self.get_brand()))
         time.sleep(0.5)
     return places
Ejemplo n.º 10
0
 def get_place_data(self):
     try:
         elements = self.driver.find_elements_by_xpath(
             '//*[@id="contents"]/div/div[2]/ul/li')
     except:
         return []
     places = []
     for element in elements:
         place_name = str(element.find_element_by_xpath('./div/div/a').text)
         name = '%s %s' % (self.brand_name, place_name)
         address = element.find_element_by_xpath(
             './div/div/div/dl[1]/dd').text
         telephone = element.find_element_by_xpath(
             './div/div/div/dl[2]/dd').text
         print(name)
         latitude, longitude = get_latlng(address, name)
         if not latitude or not longitude:
             print('[failed] %s\n%s' % (name, address))
             continue
         places.append(
             Place(name=name,
                   address=address,
                   telephone=telephone,
                   latitude=latitude,
                   longitude=longitude,
                   brand=self.get_brand()))
         time.sleep(0.5)
     return places
Ejemplo n.º 11
0
    def get_place_data(self):
        try:
            elements = self.driver.find_elements_by_xpath(
                '//*[@id="wrap"]/section/div/table/tbody/tr')
        except:
            print('추가 데이터가 없습니다.')
            return []
        places = []
        for element in elements:
            place_name = str(element.find_element_by_xpath('./td[1]').text)

            if place_name.startswith('배떡  '):
                place_name = place_name.split('배떡  ')[1]
            elif place_name.startswith('배떡 '):
                place_name = place_name.split('배떡 ')[1]
            elif place_name.startswith('배떡'):
                place_name = place_name.split('배떡')[1]
            elif place_name.startswith('배덕 '):
                place_name = place_name.split('배덕 ')[1]
            elif place_name.startswith('배덕'):
                place_name = place_name.split('배덕')[1]
            elif place_name.startswith('배달떡볶이 '):
                place_name = place_name.split('배달떡볶이 ')[1]
            elif place_name.startswith('배달떡볶이'):
                place_name = place_name.split('배달떡볶이')[1]

            if place_name.startswith('('):
                place_name = place_name.split('(')[1]
            if place_name.startswith(')'):
                place_name = place_name.split(')')[1]

            if not place_name.endswith('점'):
                place_name += '점'

            name = '%s %s' % (self.brand_name, place_name)
            print(name)
            address = element.find_element_by_xpath('./td[3]').text
            latitude, longitude = get_latlng(address, name)
            if not latitude or not longitude:
                print('[failed] %s\n%s' % (name, address))
                continue
            places.append(
                Place(name=name,
                      address=address,
                      latitude=latitude,
                      longitude=longitude,
                      brand=self.get_brand()))
            time.sleep(0.5)
        return places
Ejemplo n.º 12
0
 def get_place_data(self):
     if self.is_last_page:
         return []
     try:
         self.driver.find_element_by_xpath('//*[@id="search2"]').click()
         self.driver.find_element_by_xpath(
             '//*[@id="searchKeyword"]').send_keys('%%')
         self.driver.find_element_by_xpath(
             '//*[@id="txt"]/div/div[1]/ul/li[2]/div/div/form/input[3]'
         ).click()
         time.sleep(5)
         elements = self.driver.find_elements_by_xpath(
             '//*[@id="txt"]/div/div[1]/div/ul/li')
         time.sleep(1)
     except:
         print('추가 데이터가 없습니다.')
         return []
     places = []
     num = 1
     for element in elements:
         print(num)
         name = '%s %s' % (self.brand_name,
                           element.find_element_by_xpath('./p[1]/a').text)
         address = element.find_element_by_xpath('./p[2]').text
         telephone = element.find_element_by_xpath('./p[3]/a').text
         latitude, longitude = get_latlng(address.split('(')[0], name)
         if not latitude or not longitude:
             print('[failed] %s\n%s\n%s' % (name, address, telephone))
             continue
         print(latitude, longitude)
         places.append(
             Place(name=name,
                   address=address,
                   latitude=latitude,
                   longitude=longitude,
                   telephone=telephone,
                   brand=self.get_brand()))
         time.sleep(0.5)
         num += 1
     self.is_last_page = True
     return places
Ejemplo n.º 13
0
    def get_place_data(self):
        if not self.last_page:
            last_page_link = str(
                self.driver.find_element_by_xpath(
                    '//*[@id="section-1"]/div/div/table[2]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td[5]/a'
                ).get_attribute('href'))
            query_params = parse.parse_qs(last_page_link.split('?')[1])
            self.last_page = int(query_params['page'][0])
        elif self.page_number - 1 > self.last_page:
            return []

        elements = self.driver.find_elements_by_xpath(
            '//*[@id="section-1"]/div/div/table[1]/tbody/tr')
        places = []
        row_num = 0
        for element in elements:
            row_num += 1
            if row_num % 2 == 1:
                continue
            place_name = str(element.find_element_by_xpath('./td[2]/a').text)
            if place_name.startswith('(오픈준비중)'):
                place_name = place_name.split('(오픈준비중)')[1]
            name = '%s %s' % (self.brand_name, place_name)
            telephone = element.find_element_by_xpath('./td[4]/a').text
            address = element.find_element_by_xpath('./td[3]/a').text
            print(name)
            latitude, longitude = get_latlng(address, name)
            if not latitude or not longitude:
                print('[failed] %s\n%s\n%s' % (name, address, telephone))
                continue
            places.append(
                Place(name=name,
                      address=address,
                      latitude=latitude,
                      longitude=longitude,
                      telephone=telephone,
                      brand=self.get_brand()))
            time.sleep(0.5)
        return places
Ejemplo n.º 14
0
    def get_place_data(self):
        place_cnt = self.driver.find_element_by_xpath(
            '/html/body/div[6]/main/div/div[2]/div/div/div/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/span'
        ).text
        if int(place_cnt) < (10 * (self.page_number - 1)):
            return []

        elements = self.driver.find_elements_by_xpath(
            '/html/body/div[6]/main/div/div[2]/div/div/div/div[2]/div[1]/div[2]/div'
        )
        places = []
        for element in elements:
            place_name = element.find_element_by_xpath(
                './div/a[2]/div/div').text
            splited_name = place_name.split('달토끼의떡볶이흡입구역 ')
            if len(splited_name) > 1:
                place_name = ' '.join(splited_name[1:])
            splited_name = place_name.split('달토끼의 떡볶이 흡입구역 ')
            if len(splited_name) > 1:
                place_name = ' '.join(splited_name[1:])
            name = '%s %s' % (self.brand_name, place_name)
            address = element.find_element_by_xpath('./div/div[1]/p[1]').text
            telephone = element.find_element_by_xpath('./div/div[1]/p[2]').text
            latitude, longitude = get_latlng(address.split('(')[0], name)
            print('[%s] %s %s (%s,%s)' %
                  (name, address, telephone, latitude, longitude))
            if not latitude or not longitude:
                print('[failed] %s\n%s\n%s' % (name, address, telephone))
                continue
            places.append(
                Place(name=name,
                      address=address,
                      latitude=latitude,
                      longitude=longitude,
                      telephone=telephone,
                      brand=self.get_brand()))
            time.sleep(0.5)
        return places