crawling_time.js 1.3 KB
var async = require('async');
var webdriver = require('selenium-webdriver');
var options = {desiredCapabilities: {browserName: 'chrome'}};
var JASON = require('jason')
const {Builder, By, Key, until} = require('selenium-webdriver');
var iconv = require('iconv-lite')

    
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
        .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)
                                }
                            })
                        })
                    })
                })
            })
        })
    }
}