김승훈

update main

......@@ -5,56 +5,57 @@ var JASON = require('jason')
const {Builder, By, Key, until} = require('selenium-webdriver');
var iconv = require('iconv-lite')
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
let url1 = "https://search.naver.com/search.naver?sm=top_hty&fbm=1&ie=utf8&query=%EB%9F%B0%EB%8B%9D%EB%A7%A8"
driver
.get(url1).then(() => {
module.exports = {
search_onairanddate: function(driver,string) {
let url1 = "https://search.naver.com/search.naver?sm=top_hty&fbm=1&ie=utf8&query=" + string
driver
.findElements(webdriver.By.className('brcs_detail'))
.then(broad_info => {
broad_info[0].findElement(webdriver.By.tagName('dl'))
.then(more_data => {
more_data.findElement(webdriver.By.tagName('dd'))
.then(one_line => {
one_line.findElement(webdriver.By.className("inline"))
.then(isbroad => {
isbroad.getText()
.then(isbroad_string => {
console.log(isbroad_string)
broadcasting=isbroad_string.substring(0,4)
isbroad = isbroad_string.substring(18,21)
br_date = isbroad_string.substring(23,24)
br_date = br_date + "요일"
br_time = isbroad_string.substring(26,34)
.get(url1).then(() => {
driver
.findElements(webdriver.By.className('brcs_detail'))
.then(broad_info => {
broad_info[0].findElement(webdriver.By.tagName('dl'))
.then(more_data => {
more_data.findElement(webdriver.By.tagName('dd'))
.then(one_line => {
one_line.findElement(webdriver.By.className("inline"))
.then(isbroad => {
isbroad.getText()
.then(isbroad_string => {
console.log(isbroad_string)
broadcasting=isbroad_string.substring(0,4)
isbroad = isbroad_string.substring(18,21)
br_date = isbroad_string.substring(23,24)
br_date = br_date + "요일"
br_time = isbroad_string.substring(26,34)
console.log(broadcasting,isbroad,br_date,br_time)
if(isbroad == "방영중") {
driver.findElement(webdriver.By.id('nx_query')).clear().then(( )=> {
//var buf = iconv.encode("편성표", "euc-kr")
//console.log(buf)
//var encodestr='';
//for(var i=0; i<buf.length;i++) {
// encodestr+='%'+buf[i].toString('16')
// }
//encodestr = encodestr.toUpperCase();
//console.log(iconv.encode(encodestr, 'EUC-KR').toString())
//console.log(encodestr)
var buf = iconv.encode('편성표','euckr')
var param = buf.toString('binary')
console.log(param)
driver.findElement(webdriver.By.id('nx_query')).sendKeys(broadcasting,br_date,param)
driver.findElement(webdriver.By.className('spnew ico_search')).click()
})
}
else {
console.log(broadcasting,isbroad,br_date,br_time)
if(isbroad == "방영중") {
driver.findElement(webdriver.By.id('nx_query')).clear().then(( )=> {
//var buf = iconv.encode("편성표", "euc-kr")
//console.log(buf)
//var encodestr='';
//for(var i=0; i<buf.length;i++) {
// encodestr+='%'+buf[i].toString('16')
// }
//encodestr = encodestr.toUpperCase();
//console.log(iconv.encode(encodestr, 'EUC-KR').toString())
//console.log(encodestr)
//var buf = iconv.encode('편성표','euckr')
//var param = buf.toString('binary')
//console.log(param)
//driver.findElement(webdriver.By.id('nx_query')).sendKeys(broadcasting,br_date,param)
//driver.findElement(webdriver.By.className('spnew ico_search')).click()
})
}
}
else {
}
})
})
})
})
})
})
})
}
}
\ No newline at end of file
......
......@@ -8,70 +8,67 @@ const screen = {
};
var a=0
var breaktheloop = false
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
let url = 'https://people.search.naver.com/search.naver?where=nexearch&query=%EC%9C%A0%EC%9E%AC%EC%84%9D&sm=tab_etc&ie=utf8&key=PeopleService&os=94702';
driver
.get(url)
.then(() => {
driver.findElement(webdriver.By.id('pagination_76'))
.then ( paginationBtn => {
paginationBtn.findElements(webdriver.By.className('bt_next'))
.then(Btn_next => {
driver.findElement(webdriver.By.id('listUI_76'))
.then(contentsUI => {
contentsUI.findElements(webdriver.By.tagName('li'))
.then(elems => {
elems.forEach(elem => {
elem.getText()
.then(text => {
console.log(text)
module.exports = {
search_broadcasting : function(driver,url) {
driver
.get(url)
.then(() => {
driver.findElement(webdriver.By.id('pagination_76'))
.then ( paginationBtn => {
paginationBtn.findElements(webdriver.By.className('bt_next'))
.then(Btn_next => {
driver.findElement(webdriver.By.id('listUI_76'))
.then(contentsUI => {
contentsUI.findElements(webdriver.By.tagName('li'))
.then(elems => {
elems.forEach(elem => {
elem.getText()
.then(text => {
console.log(text)
})
})
})
})
clickandget()
function clickandget() {
Btn_next[0].isDisplayed().then(function(state) {
if(state) {
Btn_next[0].click()
sleep(500).then(()=> {
contentsUI.findElements(webdriver.By.tagName('li'))
.then(elems => {
elems.forEach(elem => {
elem.getText()
.then(text => {
console.log(text)
clickandget()
function clickandget() {
Btn_next[0].isDisplayed().then(function(state) {
if(state) {
Btn_next[0].click()
sleep(500).then(()=> {
contentsUI.findElements(webdriver.By.tagName('li'))
.then(elems => {
elems.forEach(elem => {
elem.getText()
.then(text => {
console.log(text)
})
})
})
})
})
}
else {
console.log(state)
}
})
}
}
else {
console.log(state)
}
})
}
})
})
})
})
})
function getContentsandClickNext(callback) {
driver.findElement(webdriver.By.id('listUI_76'))
.then(contentsUI => {
contentsUI.findElements(webdriver.By.tagName('li'))
.then(elems => {
elems.forEach(elem => {
elem.getTex
function getContentsandClickNext(callback) {
driver.findElement(webdriver.By.id('listUI_76'))
.then(contentsUI => {
contentsUI.findElements(webdriver.By.tagName('li'))
.then(elems => {
elems.forEach(elem => {
elem.getTex
})
})
})
})
}
}
function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
\ No newline at end of file
function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
}
}
\ No newline at end of file
......
This diff is collapsed. Click to expand it.
......@@ -5,29 +5,30 @@ var JASON = require('jason')
const {Builder, By, Key, until} = require('selenium-webdriver');
var iconv = require('iconv-lite')
var findtitle = "런닝맨"
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
let url1 = "https://search.naver.com/search.naver?sm=tab_hty.top&where=nexearch&query=SBS+%EC%9D%BC%EC%9A%94%EC%9D%BC+%ED%8E%B8%EC%84%B1%ED%91%9C&oquery=SBS+%EC%9B%94%EC%9A%94%EC%9D%BC+%ED%8E%B8%EC%84%B1%ED%91%9C&tqi=UsDTSlpySD0ssv33OfVssssssXK-499490"
driver
.get(url1).then(() => {
module.exports = {
search_broadcasting_time : function(driver,broadcast,day,findtitle) {
let url1 = "https://search.naver.com/search.naver?sm=top_hty&fbm=0&ie=utf8&query="+broadcast+"+"+day+"+편성표"
driver
.findElements(webdriver.By.className('cont_inner type_day _scheduleArea'))
.then(contentsearch_section=> {
contentsearch_section[0].findElements(webdriver.By.tagName('tbody'))
.then(tbody => {
tbody[0].findElements(webdriver.By.tagName('tr'))
.then(trs => {
trs.forEach(tr => {
tr.getText()
.then(content => {
if(content.indexOf(findtitle) != -1) {
console.log(content)
}
.get(url1).then(() => {
driver
.findElements(webdriver.By.className('cont_inner type_day _scheduleArea'))
.then(contentsearch_section=> {
contentsearch_section[0].findElements(webdriver.By.tagName('tbody'))
.then(tbody => {
tbody[0].findElements(webdriver.By.tagName('tr'))
.then(trs => {
trs.forEach(tr => {
tr.getText()
.then(content => {
if(content.indexOf(findtitle) != -1) {
console.log(content)
}
})
})
})
})
})
})
})
}
}
\ No newline at end of file
......
var async = require('async');
var webdriver = require('selenium-webdriver');
//var options = {desiredCapabilities: {browserName: 'chrome'}};
var chrome = require('selenium-webdriver/chrome')
var Options = new chrome.Options();
Options.addArguments('headless')
Options.addArguments('disable-gpu')
var JASON = require('jason')
const test1 = require('./crawling_samename')
const test2 = require('./crawling_broadcasting')
const test3 = require('./crawling_br_onair_date')
const test4 = require('./crawling_time')
const {Builder, By, Key, until} = require('selenium-webdriver');
var driver = new webdriver.Builder()
.forBrowser('chrome')
.withCapabilities(webdriver.Capabilities.chrome())
.setChromeOptions(Options)
.build();
samename_list = []
samename_list = test1.first_search(driver,"유재석")
var driver_1 = new webdriver.Builder()
.forBrowser('chrome')
.withCapabilities(webdriver.Capabilities.chrome())
.setChromeOptions(Options)
.build();
test2.search_broadcasting(driver_1,"https://people.search.naver.com/search.naver?where=nexearch&sm=tab_ppn&query=%EC%9C%A0%EC%9E%AC%EC%84%9D&os=94702&ie=utf8&key=PeopleService")
var driver_2 = new webdriver.Builder()
.forBrowser('chrome')
.withCapabilities(webdriver.Capabilities.chrome())
.setChromeOptions(Options)
.build();
test3.search_onairanddate(driver_2,"런닝맨")
var driver_3 = new webdriver.Builder()
.forBrowser('chrome')
.withCapabilities(webdriver.Capabilities.chrome())
.setChromeOptions(Options)
.build();
test4.search_broadcasting_time(driver_3,"SBS","일요일","런닝맨")
\ No newline at end of file