コード例 #1
0
ファイル: data_add.py プロジェクト: Shiwoo-Park/glance
def getSeedAddForm(param_dic, dao_util):
	sc_type = param_dic["sc_type"]
	field_info_dic = getFieldInfoDic("crawl", "seed", sc_type)
	param_dic["_data_type"] = "seed"
	load_data = dao_util.getDataList(param_dic, "unique")
	data_dic = getDataDic(load_data, field_info_dic["select"])
	if data_dic["domain_id"]:
		param_dic["domain_id"] = data_dic["domain_id"]
	elif param_dic["domain_id"]:
		data_dic["domain_id"] = param_dic["domain_id"]

	seed_type_dic = getDataMappingDic(param_dic["_service_type"], param_dic["_data_type"], "seed_type")
	html_seed_type = "<option value='%s'>%s</option>"%(data_dic["seed_type"], data_dic["seed_type"])
	for seedTypeData in seed_type_dic.items():
		html_seed_type += "<option value='%s'>%s</option>"%seedTypeData

	status_dic = getDataMappingDic(param_dic["_service_type"], param_dic["_data_type"], "crawl_status")
	html_status = "<option value='%s'>%s</option>"%(data_dic["crawl_status"], data_dic["crawl_status"])
	for statusData in status_dic.items():
		html_status += "<option value='%s'>%s</option>"%statusData

	added_form = ""
	if sc_type == "oi":
		added_form += """
		<tr> <td>모바일URL</td> <td><input type='text' name='mobile_url' class='textInput' value='%s' style="width:200px;"/></td> </tr>
		<tr> <td>토픽</td> <td><input type='text' name='topic' class='textInput' value='%s' style="width:200px;"/></td> </tr>
		"""%(data_dic["mobile_url"], data_dic["topic"])
	elif sc_type == "blog":
		added_form += """
		<tr> <td>블로그 ID</td> <td><input type='text' name='blog_id' class='textInput' value='%s' style="width:100px;"/></td> </tr>
		<tr> <td>블로그 링크</td> <td><input type='text' name='link' class='textInput' value='%s' style="width:200px;"/></td> </tr>
		"""%(data_dic["blog_id"], data_dic["link"])

	html_form = """
	<form id='seedAddForm' action='/moon/action/sc_common.py' method='post'>
		<input type='hidden' name='cmd' value='addUpdate' />
		<input type='hidden' name='_data_type' value='seed' />
		<input type='hidden' name='sc_type' value='%s' />
		<input type='hidden' name='seed_id' value='%s' />
		<input type='hidden' name='domain_id' value='%s' />
	"""%(sc_type, data_dic["seed_id"], data_dic["domain_id"])+"""
		<table>
			<tr style='color:red; font-weight:800;'>
				<td>씨드ID</td> <td>도메인ID</td> <td>뷰URL 수</td>
				<td>신규URL<br/>미발견 횟수</td> <td>마지막방문</td> <td>Generator</td>
			</tr>
			<tr>
				<td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td>
			</tr>
		</table>
	"""%(data_dic["seed_id"],data_dic["domain_id"],data_dic["view_url_count"],data_dic["no_new_count"],getDateByStamp(data_dic["last_visit"]),data_dic["generator"])+"""
		<table class="formTable">
			<tr> <td>씨드URL GUID</td> <td><input type='text' name='seed_guid' class='textInput' value='%s' style="width:300px;"/></td> </tr>
			<tr> <td>다운로드URL</td> <td><input type='text' name='down_url' class='textInput' value='%s' style="width:300px;"/></td> </tr>
			<tr> <td>씨드명</td> <td><input type='text' name='seed_name' class='textInput' value='%s' style="width:200px;"/></td> </tr>
			<tr> <td>INT_ID최대값</td> <td><input type='text' name='max_no' class='textInput' value='%s' style="width:200px;"/></td> </tr>
			<tr> <td>씨드타입</td> <td><select form='seedAddForm' name='seed_type'>%s</select> 기본값 : 숫자(N)</td>
			<tr> <td>크롤상태</td> <td><select form='seedAddForm' name='crawl_status'>%s</select> 기본값 : 준비중(W)</td>
			%s
		</table>
		<input type="submit" value="등록 (혹은 수정)" style=" width:420px; font-weight:800; color:red;"/>
	</form>
	"""%(data_dic["seed_guid"], data_dic["down_url"], data_dic["seed_name"], data_dic["max_no"], html_seed_type, html_status, added_form)

	return html_form
コード例 #2
0
ファイル: domain_list.py プロジェクト: Shiwoo-Park/glance
def getTableAndPagingHtml(param_dic, dao_util):
	if not dao_util:
		return "", ""
	if not param_dic["sc_type"]:
		return "", ""

	if param_dic["page"]:
		page = int(param_dic["page"])
		param_dic["page"] = page+1
		next_page_get_params = html.getGetParamStr(param_dic)
		param_dic["page"] = page-1
		if (page-1) < 1:
			param_dic["page"] = 1
		prev_page_get_params = html.getGetParamStr(param_dic)
		param_dic["page"] = page
	else:
		param_dic["page"] = 2
		next_page_get_params = html.getGetParamStr(param_dic)
		param_dic["page"] = 1
		prev_page_get_params = html.getGetParamStr(param_dic)

	sc_type = param_dic["sc_type"]
	status_dic = getDataMappingDic(param_dic["_service_type"], param_dic["_data_type"], "status")
	data_list = dao_util.getDataList(param_dic, "web")

	col_name_list = ["도메인ID<br/>(클릭 시 수정)", "도메인", "사이트명<br/>(메모)", "상태", "서버", "PID",
					 "씨드URL수%s"%(html.getOrderingLinkHtml("/moon/crawl/domain_list.py", param_dic, "seed_url_count")),
					 "신규URL수%s<br/>(최근7일 현황)"%(html.getOrderingLinkHtml("/moon/crawl/domain_list.py", param_dic, "daily_count")),
					 "마지막 크롤일%s"%(html.getOrderingLinkHtml("/moon/crawl/domain_list.py", param_dic, "last_visit"))]

	if param_dic["sc_type"] == "user":  # TODO SC별 테이블 CUSTOMIZING
		col_name_list.append("새컬럼명")
	col_name_list.append("관리")

	html_title_row = html.getTableTR(col_name_list, "title")
	html_table = "<table style='table-layout:fixed; word-break:break-all;'>"+html_title_row
	row_count = 0

	# MAKE TABLE HTML
	for row_data in data_list:
		domain_id = row_data[0]
		domain = row_data[1]
		name = row_data[2]
		memo = row_data[3]
		if memo:
			name = "%s<br/>(%s)"%(name, memo)
		status = row_data[4]
		if status:
			status = status_dic[status]
		server = row_data[5]
		pid = row_data[6]
		seed_url_count = row_data[7]
		daily_count = row_data[8]
		crawl_count_history = row_data[9]
		last_visit = row_data[10]
		if last_visit:
			last_visit = getDateByStamp(last_visit)
		else:
			last_visit = ""

		added_td_tags = ""
		if sc_type == "user":  # TODO 표시 데이터 SC별 CUSTOMIZING
			added_td_tags += "<td>%s</td>"%row_data[11]

		if (row_count % 2) == 0:
			html_row = "<tr class='evenRow'>"
		else:
			html_row = "<tr>"

		document_view_link = "http://topicplus.zuminternet.com/recent_documents.py?sc=%s&channelId=%s"%(sc_type, domain_id)
		if sc_type == "bbs":
			document_view_link = "http://topicplus.zuminternet.com/recent_documents.py?sc=%s&siteId=%s"%(sc_type, domain_id)

		html_row += """
			<td><a href="/moon/domanager/domain_add.py?domainIdx=%s" target="_blank">%s</a></td>
			<td><a href="%s" target="_blank">%s</a><br/>
				<a href="/moon/domanager/urlpt_list.py?domainLike=%s" target='_blank'>URL패턴</a> |
				<a href="/moon/crawl/seedurl_list.py?sc_type=%s&domain_id=%s" target='_blank'>씨드URL</a><br/>
				<a href="/moon/domanager/sitemapurl_list.py?domain_id=%s" target='_blank'>사이트맵URL</a>
			</td>
			"""%(domain_id, domain_id, "http://"+domain, domain,  domain, sc_type, domain_id, domain_id)+"""
			<td>%s</td>
			<td>%s</td>
			<td>%s</td>
			<td>%s</td>
			<td>%s</td>
			<td>
				<a href="%s" target="_blank" >%s</a>
				<br/>%s
			</td>
			<td>%s</td>
			"""%(name, status, server, pid, seed_url_count, document_view_link, daily_count, crawl_count_history, last_visit)+ added_td_tags +"""
			<td>
				<a href="/moon/crawl/data_add.py?sc_type=%s&domain_id=%s" target="_blank" >수정</a> &nbsp;|&nbsp;
				<a href="#" onclick="confirmPopup('%s','/moon/action/sc_common.py?cmd=del&sc_type=%s&_data_type=domain&domain_id=%s')">삭제</a><br/>
				<a href="/moon/crawl/data_add.py?sc_type=%s&domain_id=%s#seedAddForm" target="_blank" >씨드등록</a> &nbsp;|&nbsp;
				<a href="#" onclick="confirmPopup2('%s','/moon/action/sc_common.py?cmd=del&sc_type=%s&_data_type=seed&domain_id=%s')">씨드삭제</a><br/>
				<a href="/moon/action/sc_common.py?cmd=resetNoNewCount&sc_type=%s&domain_id=%s" target="_blank" >씨드전체 신규문서<br/>미발견 횟수 초기화</a>
			</td>
		</tr>
		"""%(sc_type, domain_id, domain, sc_type, domain_id, sc_type, domain_id, domain, sc_type, domain_id, sc_type, domain_id)
		html_table += html_row
		row_count += 1

	# MAKE PAGING HTML
	total_count = dao_util.getDataList(param_dic, "count")
	total_page = total_count / 15
	if (total_count % 15) > 0:
		total_page += 1
	html_paging = """
	<p>
		<b>페이지 [%s/%s]</b> : <b style='color:red;'>%s</b> 개중 <b style='color:red;'>%s</b> 개 표시
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<a href='/moon/crawl/domain_list.py?%s#tableDiv'>&lt;&lt;이전</a> || <a href='/moon/crawl/domain_list.py?%s#tableDiv'>다음&gt;&gt;</a>
	</p>
	"""%( param_dic["page"], total_page, total_count, len(data_list), prev_page_get_params, next_page_get_params)

	return html_table+"</table>", html_paging
コード例 #3
0
ファイル: seedurl_list.py プロジェクト: Shiwoo-Park/glance
def getTableAndPagingHtml(param_dic, dao_util):
    if not dao_util:
        return "", ""
    if not param_dic["sc_type"]:
        return "", ""

    if param_dic["page"]:
        page = int(param_dic["page"])
        param_dic["page"] = page + 1
        next_page_get_params = html.getGetParamStr(param_dic)
        param_dic["page"] = page - 1
        if (page - 1) < 1:
            param_dic["page"] = 1
        prev_page_get_params = html.getGetParamStr(param_dic)
        param_dic["page"] = page
    else:
        param_dic["page"] = 2
        next_page_get_params = html.getGetParamStr(param_dic)
        param_dic["page"] = 1
        prev_page_get_params = html.getGetParamStr(param_dic)

    data_list = dao_util.getDataList(param_dic, "web")
    sc_type = param_dic["sc_type"]

    col_name_list = [
        "ID",
        "씨드 URL 정보",
        "씨드명<br/>(앵커값)",
        "Generator",
        "크롤상태<br/>(씨드타입)",
        "view URL수<br/><b style='color:#6495ed;'>신규URL미발견 횟수</b><br/>INT_ID최대값",
        "마지막 방문일",
    ]

    if sc_type == "blog":  # TODO : SC별 TITLE 행 표시 데이터 CUSTOMIZING
        col_name_list[2] = "채널명<br/>(작성자)"  # 씨드명 대신 표시
        col_name_list[3] = "Generator<br/>(블로그ID)"  # 앵커TEXT 대신 표시
        # col_name_list.append("새컬럼명")

    col_name_list.append("관리")
    html_title_row = html.getTableTR(col_name_list, "title")
    html_table = "<table style='table-layout:fixed; word-break:break-all;'>" + html_title_row

    # MAKE TABLE HTML
    type_dic = getDataMappingDic(param_dic["_service_type"], param_dic["_data_type"], "seed_type")
    status_dic = getDataMappingDic(param_dic["_service_type"], param_dic["_data_type"], "crawl_status")
    row_count = 0
    for row_data in data_list:
        seed_id = row_data[0]
        domain_id = row_data[1]
        seed_guid = row_data[2]
        down_url = row_data[3]
        seed_name = "<b>%s</b>" % row_data[4]
        seed_type = row_data[5]
        if seed_type:
            seed_type = type_dic[seed_type]
        anchor_name = row_data[6]
        if anchor_name:
            seed_name = "%s<br/>(%s)" % (seed_name, anchor_name)
        crawl_status = row_data[7]
        status = ""
        if crawl_status:
            status = "크롤:<b>%s</b>" % status_dic[crawl_status]
        status += "<br/>타입:<b>%s</b>" % seed_type
        view_url_count = "뷰수:<b>%s</b><br/>" % row_data[8]
        no_new_count = "<b style='color:blue;'>노뉴:%s</b><br/>" % row_data[9]
        max_no = "맥스:<b>%s</b>" % row_data[10]
        numbers = view_url_count + no_new_count + max_no
        last_visit = row_data[11]
        generator = row_data[12]

        if last_visit:
            last_visit = getDateByStamp(last_visit)
        else:
            last_visit = ""

            # TODO : SC별 데이터 행 표시 데이터 CUSTOMIZING
        added_url_info = ""
        added_td_tags = ""
        if sc_type == "blog":
            if row_data[13]:  # 블로그 ID
                generator += "<br/>(%s)" % row_data[13]

            if row_data[14]:  # 블로그 링크
                added_url_info = "<a href='%s' target='_blank'>해당 블로그 바로가기</a><br/>" % row_data[14]

            if row_data[15]:  # author
                seed_name += "<br/>작성자 : %s" % row_data[15]

                # ROW 데이터 표시 시작
        if (row_count % 2) == 0:
            html_row = "<tr class='evenRow'>"
        else:
            html_row = "<tr>"

        html_row += (
            """
			<td>%s</td>
			<td>
				<b style="color:red;">%s</b><br/>
				%s
				도메인ID:<a href="/moon/domanager/domain_add.py?domainIdx=%s">%s</a>&nbsp;&nbsp;
				<a href="%s" target="_blank" >다운로드URL</a>
			</td>
			"""
            % (seed_id, seed_guid.replace("&", "&amp;"), added_url_info, domain_id, domain_id, down_url)
            + """
			<td>%s</td>
			<td>%s</td>
			<td>%s</td>
			<td>%s</td>
			<td>%s</td>
			"""
            % (seed_name, generator, status, numbers, last_visit)
            + added_td_tags
            + """
			<td>
				<a href="/moon/crawl/data_add.py?sc_type=%s&seed_id=%s" target="_blank" >수정</a> &nbsp;|&nbsp;
				<a href="/moon/action/sc_common.py?sc_type=%s&cmd=blockSeed&seed_id=%s" target="_blank" >차단</a> &nbsp;|&nbsp;
				<a href="#" onclick="confirmPopup('%s','/moon/action/sc_common.py?cmd=del&sc_type=%s&_data_type=seed&seed_id=%s')">삭제</a>
				<br/><a href="/moon/action/sc_common.py?cmd=resetNoNewCount&sc_type=%s&seed_id=%s" target="_blank" >신규URL수 초기화</a>
				<br/><a href="/moon/domanager/pattern_add.py?urlTypeTestUrl=%s" target="_blank">URL추출 TEST</a>
			</td>
		</tr>
		"""
            % (
                sc_type,
                seed_id,
                sc_type,
                seed_id,
                seed_guid,
                sc_type,
                seed_id,
                sc_type,
                seed_id,
                urllib2.quote(down_url),
            )
        )
        html_table += html_row
        row_count += 1

        # MAKE PAGING HTML
    total_count = dao_util.getDataList(param_dic, "count")
    total_page = total_count / 15
    if (total_count % 15) > 0:
        total_page += 1
    html_paging = """
	<p>
		<b>페이지 [%s/%s]</b> : <b style='color:red;'>%s</b> 개중 <b style='color:red;'>%s</b> 개 표시
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<a href='/moon/crawl/seedurl_list.py?%s#tableDiv'>&lt;&lt;이전</a> || <a href='/moon/crawl/seedurl_list.py?%s#tableDiv'>다음&gt;&gt;</a>
	</p>
	""" % (
        param_dic["page"],
        total_page,
        total_count,
        len(data_list),
        prev_page_get_params,
        next_page_get_params,
    )

    return html_table + "</table>", html_paging