예제 #1
0
        time.sleep(2)
        # pip install bs4
        # 혖재 페이지를 beautifulsoup의 DOM으로 구성
        soup = bs(driver.page_source, 'html.parser')
        # 현제 상세 정보 페이지에서 스케줄 정보 획득
        data = soup.select('.tip-cover')
        # print( type(data), len(data), type(data[0].contents)  )
        # 디비 입력 => pip install pymysql
        # 데이터 sum
        content_final = ''
        for c in data[0].contents:
            content_final += str(c)

        # html 콘첸츠 데이터 전처리 (디비에 입력 가능토록)
        import re

        content_final = re.sub("'", '"', content_final)
        content_final = re.sub(re.compile(r'\r\n|\r|\n|\n\r+'), '',
                               content_final)

        print(content_final)
        # 콘텐츠 내용에 따라 전처리 => data[0].contents
        db.db_insertCrawlingData(tour.title, tour.price[:-1],
                                 tour.area.replace('출발 가능 기간 : ', ''),
                                 content_final, keyword)

# 종료
driver.close()

import sys
sys.exit()
예제 #2
0
    print(type(tour))
    # 링크데이터에서 실데이터 획득
    # 분해
    arr = tour.link.split(',')
    if arr:
        # 대체
        link = arr[0].replace('searchModule.OnClickDetail(', '')
        # 슬라이싱 => 앞에 ', 뒤에 ' 제거
        detail_url = link[1:-1]
        # 상세 페이지 이동 : URL 값이 완성된 형태인지 확인 (http~)
        driver.get(detail_url)
        time.sleep(1)
        # 현재 페이지를 bs4의 DOM으로 구성
        soup = bs(driver.page_source, 'html.parser')
        # 현재 상세 정보 페이지에서 스케줄 정보 획득
        data = soup.select('.tip-cover')
        print(type(data), len(data), data[0].contents)
        # DB 입력
        content_final = ''
        # for c in data[0].contents:
        #     contnet_final = str(c)

        # 컨텐츠 내용에 따라 전처리
        db.db_insertCrawlingData(tour.title, tour.price, tour.area,
                                 data[0].contents, keyword)

# 종료
driver.close()
driver.quit()
sys.exit()
예제 #3
0
        link_notnull = 'None'
    else:
        link_notnull = iteminfo.link

    img_notnull = ''
    if not iteminfo.img:
        img_notnull = 'None'
    else:
        img_notnull = iteminfo.img

    # 콘텐츠 내용에 따라서 전처리 => data[0].contents
    db.db_insertCrawlingData(
            iteminfo.title,
            iteminfo.price,
            '',
            '',
            keyword,
            img_notnull,
            link_notnull
    )

# 종료

driver.close()
driver.quit()
sys.exit()

# 추가 작업
# proxy , agent
# mobile, pc 구분
# image 제거
예제 #4
0
파일: run.py 프로젝트: rheehot/itemcrawling
        #DB 입력 => pip install pymysql
        # 데이터 sum
        content_final = ''
        for c in data[0].contents:
            content_final += str(c)

        # html 콘첸츠 데이터 전처리 (디비에 입력 가능토록)
        import re
        content_final   = re.sub("'", '"', content_final)
        content_final   = re.sub(re.compile(r'\r\n|\r|\n|\n\r+'), '', content_final)

        # 콘텐츠 내용에 따라서 전처리 => data[0].contents
        db.db_insertCrawlingData(
                tour.title,
                tour.price,
                tour.area,
                content_final,
                keyword
        )

# 종료

driver.close()
driver.quit()
import sys
sys.exit()

# 추가 작업
# proxy , agent
# mobile, pc 구분
# image 제거