crawling_time.js 1.38 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')

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(() => {
        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)
                            }
                        })
                    })
                })
            })
        })
    })