Showing
1 changed file
with
60 additions
and
0 deletions
동명이인/sdfasdfasd.js
0 → 100644
1 | +var async = require('async'); | ||
2 | +var webdriver = require('selenium-webdriver'); | ||
3 | +//var options = {desiredCapabilities: {browserName: 'chrome'}}; | ||
4 | +var chrome = require('selenium-webdriver/chrome') | ||
5 | +var Options = new chrome.Options(); | ||
6 | +Options.addArguments('headless') | ||
7 | +Options.addArguments('disable-gpu') | ||
8 | +var test1 = require('./crawling_samename') | ||
9 | +const fs = require('fs') | ||
10 | +var util = require('util') | ||
11 | +var EventEmitter = require('events').EventEmitter; | ||
12 | + | ||
13 | +var next_link_Array = [] | ||
14 | +var img_src_Array = [] | ||
15 | + | ||
16 | +const {Builder, By, Key, until} = require('selenium-webdriver'); | ||
17 | +var driver = new webdriver.Builder() | ||
18 | +.forBrowser('chrome') | ||
19 | +.withCapabilities(webdriver.Capabilities.chrome()) | ||
20 | +.setChromeOptions(Options) | ||
21 | +.build(); | ||
22 | + | ||
23 | +var First_Search = function(name) { | ||
24 | + var self=this; | ||
25 | + this.on('input', function() { | ||
26 | + | ||
27 | + if(fs.existsSync("./log/"+name+"_next_link.txt")) { | ||
28 | + const next_link = fs.readFileSync("./log/"+name+"_next_link.txt"); | ||
29 | + const img_src = fs.readFileSync("./log/"+name+"_img_src.txt"); | ||
30 | + next_link_Array = next_link.toString().split(','); | ||
31 | + img_src_Array = img_src.toString().split(','); | ||
32 | + driver.quit() | ||
33 | + console.log(next_link_Array) | ||
34 | + console.log(img_src_Array) | ||
35 | + | ||
36 | + setTimeout(function() { | ||
37 | + br_search.emit('click') | ||
38 | + },1000) | ||
39 | + | ||
40 | + } | ||
41 | + else { | ||
42 | + test1.first_search(driver,name,function() { | ||
43 | + const next_link = fs.readFileSync("./log/"+name+"_next_link.txt"); | ||
44 | + const img_src = fs.readFileSync("./log/"+name+"_img_src.txt"); | ||
45 | + next_link_Array = next_link.toString().split(','); | ||
46 | + img_src_Array = img_src.toString().split(','); | ||
47 | + br_search = new broadcasting_search(next_link_Array,"유재석",0) | ||
48 | + console.log(next_link_Array) | ||
49 | + console.log(img_src_Array) | ||
50 | + driver.quit() | ||
51 | + setTimeout(function() { | ||
52 | + br_search.emit('click') | ||
53 | + },1000) | ||
54 | + }) | ||
55 | + } | ||
56 | + }) | ||
57 | +} | ||
58 | +util.inherits(First_Search,EventEmitter); | ||
59 | +first_search1 = new First_Search("유재석") | ||
60 | +first_search1.emit('input') |
-
Please register or login to post a comment