{"id":10768,"date":"2022-07-25T07:00:54","date_gmt":"2022-07-24T22:00:54","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=10768"},"modified":"2022-07-14T05:25:13","modified_gmt":"2022-07-13T20:25:13","slug":"%e3%83%98%e3%83%83%e3%83%89%e3%83%ac%e3%82%b9-chrome-%e3%81%a7%e7%89%b9%e5%ae%9a%e3%82%b5%e3%82%a4%e3%83%88%e3%81%ae%e3%82%af%e3%83%ad%e3%83%bc%e3%83%a9%e3%83%bc%e3%82%92%e3%81%a4%e3%81%8f%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=10768","title":{"rendered":"\u30d8\u30c3\u30c9\u30ec\u30b9 Chrome \u3067\u7279\u5b9a\u30b5\u30a4\u30c8\u306e\u30af\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u3068\u3053\u308d<code>Laravel<\/code>\u3084<code>Vue<\/code>\u95a2\u9023\u306e\u8a18\u4e8b\u3070\u304b\u308a\u66f8\u3044\u3066\u3044\u305f\u306e\u3067\u3001\u305f\u307e\u306b\u306f\u300c<strong>\uff19\u56de\u30ab\u30ec\u30fc\u3060\u3063\u305f\u3089\u3001\u6b21\u306f\u30cf\u30e4\u30b7\u30e9\u30a4\u30b9<\/strong>\u300d\u7684\u306a\u6c17\u5206\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u3058\u3083\u3042\u4f55\u304c\u3044\u3044\u304b\u306a\u3068\u8003\u3048\u3066\u3044\u305f\u3068\u3053\u308d\u904e\u53bb\u306b\u3084\u3063\u3066\u307f\u305f\u3042\u308b\u5185\u5bb9\u304c\u601d\u3044\u6d6e\u304b\u3073\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u306f\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 35px;\">\u300c\u30d8\u30c3\u30c9\u30ec\u30b9 Chrome\u300d<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p><strong>\ud83d\udcdd \u53c2\u8003\u30da\u30fc\u30b8\uff1a<\/strong>\u00a0<a href=\"https:\/\/blog.capilano-fw.com\/?p=5321\">JavaScript\u3067\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u3066\u308b\u30da\u30fc\u30b8\u3092\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u3059\u308b\u65b9\u6cd5<\/a><\/p>\n<p>\u300c<strong>\u30d8\u30c3\u30c9\u30ec\u30b9 Chrome<\/strong>\u300d\u3068\u306f\u3001\u30b7\u30f3\u30d7\u30eb\u306b\u8a00\u3046\u3068\u300c<strong>\u76ee\u306b\u898b\u3048\u308b\u90e8\u5206\u304c\u306a\u3044 \uff1d \u982d\u304c\u306a\u3044 \uff1d \u30d8\u30c3\u30c9\u30ec\u30b9<\/strong>\u300d\u306e\u3053\u3068\u3067\u3001\u305d\u306e\u5206\u9ad8\u901f\u306b\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u305f\u3081\u3001\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u306a\u3069\u306b\u5229\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3057\u304b\u3082\u3001\u30d8\u30c3\u30c9\u30ec\u30b9\u3068\u306f\u8a00\u3048\u3001\u3061\u3083\u3093\u3068\u3057\u305f\u30d6\u30e9\u30a6\u30b6\u306a\u306e\u3067\u3001\u306a\u3093\u3068\u2026<\/p>\n<p><strong style=\"font-size: 35px;\">JavaScript\u306e\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u308b\uff01<\/strong><\/p>\n<p>\u306e\u304c<code>PHP<\/code>\u306e<code>Guzzle<\/code>\u3068\u306e\u5927\u304d\u306a\u9055\u3044\u3067\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u2757<\/p>\n<p>\u4eca\u56de\u306f<code>Node.js<\/code>\u3092\u4f7f\u3063\u3066\u300c<strong>\u30d8\u30c3\u30c9\u30ec\u30b9 Chrome<\/strong>\u300d\u3092\u64cd\u4f5c\u3057\u3001\u7279\u5b9a\u306e\u30b5\u30a4\u30c8\u3060\u3051\u306b\u7d5e\u3063\u305f\u30af\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u3063\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u305c\u3072\u4f55\u304b\u306e\u53c2\u8003\u306b\u306a\u308c\u3070\u5b09\u3057\u3044\u3067\u3059\u3002\ud83d\ude0a\u2728<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9470 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/08\/no_13.png\" alt=\"\" width=\"294\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/08\/no_13.png 294w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/08\/no_13-276x300.png 276w\" sizes=\"auto, (max-width: 294px) 100vw, 294px\" \/>\u300c\u304a\u6c17\u306b\u5165\u308a\u306e\u30d3\u30fc\u30eb\u91b8\u9020\u6240\u304c<br \/>\n\u304a\u6c17\u306b\u5165\u308a\u3060\u3063\u305f\u98a8\u5473\u306e\u30d3\u30fc\u30eb<br \/>\n\u3092\u51fa\u3057\u3066\u3066\u611f\u52d5\ud83d\udc4d\u300d<\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> NodeJS v16.15.0<\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u4eca\u56de\u306f\u300c<strong>\u30e4\u30d5\u30fc\u30cb\u30e5\u30fc\u30b9<\/strong>\u300d\u306e\u30b5\u30a4\u30c8\u5185\u306b\u300c<strong>\u653f\u5e9c<\/strong>\u300d\u3068\u3044\u3046\u8a00\u8449\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\u304b\u3068\u3044\u3046\u30af\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u203b \u306a\u304a\u3001\u300c<strong>\u653f\u5e9c<\/strong>\u300d\u3068\u3044\u3046\u30ad\u30fc\u30ef\u30fc\u30c9\u306f\u6bd4\u8f03\u7684\u591a\u3081\u306b\u5165\u3063\u3066\u3044\u308b\u3088\u3046\u3067\u3057\u305f\u306e\u3067\u3001\u6c7a\u5b9a\u3057\u307e\u3057\u305f\u3002\uff08\u30db\u30f3\u30c8\u306f\u300c\u660e\u77f3\u5bb6\u3055\u3093\u307e\u300d\u304c\u826f\u304b\u3063\u305f\u3093\u3067\u3059\u3051\u3069\u306d\ud83d\ude02\uff09<\/p>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u4f5c\u696d\u3092\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u2757<\/p>\n<h1>\u30d8\u30c3\u30c9\u30ec\u30b9 Chrome \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h1>\n<p>\u307e\u305a\u306f\u300c<strong>\u30d8\u30c3\u30c9\u30ec\u30b9 Chrome<\/strong>\u300d\u304c\u306a\u3044\u3068\u306f\u3058\u307e\u308a\u307e\u305b\u3093\u306e\u3067\u3001\u4ee5\u4e0b\u306eURL\u3092\u53c2\u8003\u306b\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u6e08\u307e\u305b\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>\ud83d\udcdd \u53c2\u8003\u30da\u30fc\u30b8\uff1a<\/strong>\u00a0<a href=\"https:\/\/blog.capilano-fw.com\/?p=5321\">JavaScript\u3067\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u3066\u308b\u30da\u30fc\u30b8\u3092\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u3059\u308b\u65b9\u6cd5<\/a><\/p>\n<h1>\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h1>\n<p>\u4eca\u56de\u306f<code>NodeJS<\/code>\u304b\u3089<code>MySQL<\/code>\u306b\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>npm install mysql<\/strong><\/pre>\n<h1>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30c6\u30fc\u30d6\u30eb\u3092\u7528\u610f\u3059\u308b<\/h1>\n<p>\u3067\u306f\u3001\u30af\u30ed\u30fc\u30e9\u30fc\u304c\u30a2\u30af\u30bb\u30b9\u3057\u305f\u6642\u306b\u53d6\u5f97\u3059\u308b\u3053\u3068\u306b\u306a\u308b<code>URL<\/code>\u3092\u4fdd\u5b58\u3059\u308b\u30c6\u30fc\u30d6\u30eb<code>crawler_urls<\/code>\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\uff08\u79c1\u306e\u74b0\u5883\u3067\u306f<code>adminer<\/code>\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u304c\u3001<code>PhpMyAdmin<\/code>\u3067\u3082\u540c\u3058\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u306e\u3067\u540c\u3058\u30c6\u30fc\u30d6\u30eb\u69cb\u9020\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10772\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/07\/headless_chrome_crawler_1.png\" alt=\"\" width=\"558\" height=\"366\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/07\/headless_chrome_crawler_1.png 558w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/07\/headless_chrome_crawler_1-300x197.png 300w\" sizes=\"auto, (max-width: 558px) 100vw, 558px\" \/><\/p>\n<p>\u306a\u304a\u3001\u4ee5\u4e0b\u306e\u90e8\u5206\u306b\u306f\u304a\u6c17\u3092\u3064\u3051\u304f\u3060\u3055\u3044\u3002<\/p>\n<ul>\n<li>has_keyword \u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306b\u300cfalse\u300d\u304c\u3064\u3044\u3066\u3044\u308b<\/li>\n<li>url \u306b\u306f\u3001UNIQUE\u5236\u9650\u304c\u3064\u3044\u3066\u3044\u308b<\/li>\n<\/ul>\n<p>\uff08\u3053\u3046\u3044\u3046\u4f5c\u696d\u3092\u3084\u308b\u3068\u3001<code>Laravel<\/code>\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3063\u3066\u4fbf\u5229\u3060\u3068\u611f\u3058\u307e\u3059\u306d\ud83d\ude02\uff09<\/p>\n<h1>\u30af\u30ed\u30fc\u30e9\u30fc\u306e\u30b3\u30fc\u30c9\u3092\u66f8\u304f<\/h1>\n<p>\u3067\u306f\u3001\u3053\u3053\u304b\u3089\u304c\u30e1\u30a4\u30f3\u306e<code>Node.js<\/code>\u30b3\u30fc\u30c9\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u3053\u3061\u3089\u3067\u3059\u3002<br \/>\n\u2193\u3000\u2193\u3000\u2193<\/p>\n<p><strong>crawler.js<\/strong><\/p>\n<pre><strong>\/\/ Constants<\/strong>\r\n<strong>const CRAWLER_TOP_URL = 'https:\/\/news.yahoo.co.jp\/'; \/\/ \u30e4\u30d5\u30fc\u30cb\u30e5\u30fc\u30b9<\/strong>\r\n<strong>const KEYWORD = '\u653f\u5e9c'; \/\/ \u63a2\u3057\u305f\u3044\u30ad\u30fc\u30ef\u30fc\u30c9<\/strong>\r\n\r\n<strong>\/\/ DB<\/strong>\r\n<strong>const mysql = require('mysql');<\/strong>\r\n<strong>const util = require('util');<\/strong>\r\n<strong>const { exit } = require('process');<\/strong>\r\n<strong>const connection = mysql.createConnection({<\/strong>\r\n<strong>    host: 'localhost',<\/strong>\r\n<strong>    user: '\uff08MySQL \u306e\u30e6\u30fc\u30b6\u30fc\u540d\uff09',<\/strong>\r\n<strong>    password: '\uff08MySQL \u306e\u30d1\u30b9\u30ef\u30fc\u30c9\uff09',<\/strong>\r\n<strong>    database: 'crawler'<\/strong>\r\n<strong>});<\/strong>\r\n<strong>const query = util.promisify(connection.query).bind(connection);<\/strong>\r\n<strong>const getCrawlerUrl = async () =&gt; {<\/strong>\r\n\r\n<strong>    const sql = 'SELECT * FROM crawler_urls ORDER BY RAND() LIMIT 1';<\/strong>\r\n<strong>    const rows = await query(sql);<\/strong>\r\n\r\n<strong>    if(rows.length &gt; 0) {<\/strong>\r\n\r\n<strong>        return rows[0].url;<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n<strong>    return CRAWLER_TOP_URL;<\/strong>\r\n\r\n<strong>}<\/strong>\r\n<strong>const saveCrawlerUrls = async (urls) =&gt; {<\/strong>\r\n\r\n<strong>    for(const url of urls) {<\/strong>\r\n\r\n<strong>        const sql = 'INSERT INTO crawler_urls (url) VALUES (?) ON DUPLICATE KEY UPDATE url = ?';<\/strong>\r\n<strong>        const values = [url, url];<\/strong>\r\n<strong>        await query(sql, values);<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n<strong>};<\/strong>\r\n<strong>const saveHasKeyword = async (hasKeyword, url) =&gt; {<\/strong>\r\n\r\n<strong>    const sql = 'UPDATE crawler_urls SET has_keyword = ?, crawled_at = ? WHERE url = ?';<\/strong>\r\n<strong>    const values = [hasKeyword, new Date(), url];<\/strong>\r\n<strong>    await query(sql, values);<\/strong>\r\n\r\n<strong>};<\/strong>\r\n\r\n<strong>\/\/ Crawler<\/strong>\r\n<strong>const puppeteer = require('puppeteer');<\/strong>\r\n<strong>const url = require('url');<\/strong>\r\n<strong>const getTargetHostNameUrl = targetUrls =&gt; { \/\/ \u30c9\u30e1\u30a4\u30f3\u304c CRAWLER_TOP_URL \u3068\u540c\u3058\u3082\u306e\u3060\u3051\u62bd\u51fa<\/strong>\r\n\r\n<strong>    const baseHostName = url.parse(CRAWLER_TOP_URL).hostname;<\/strong>\r\n\r\n<strong>    return targetUrls.filter(targetUrl =&gt; {<\/strong>\r\n\r\n<strong>        if(! targetUrl) {<\/strong>\r\n\r\n<strong>            return false;<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>        const hostName = url.parse(targetUrl).hostname;<\/strong>\r\n<strong>        return hostName === baseHostName;<\/strong>\r\n\r\n<strong>    });<\/strong>\r\n\r\n<strong>};<\/strong>\r\n\r\n<strong>(async() =&gt; {<\/strong>\r\n\r\n<strong>    \/\/ \u3053\u308c\u304b\u3089\u30af\u30ed\u30fc\u30eb\u3059\u308b URL \u3092 DB \u304b\u3089\u53d6\u5f97\u3059\u308b<\/strong>\r\n<strong>    const crawlerUrl = await getCrawlerUrl();<\/strong>\r\n<strong>    console.log('Crawling URL: '+ crawlerUrl);<\/strong>\r\n\r\n<strong>    \/\/ \u30d8\u30c3\u30c9\u30ec\u30b9 Chrome \u3067\u30a2\u30af\u30bb\u30b9<\/strong>\r\n<strong>    const browser = await puppeteer.launch();<\/strong>\r\n<strong>    const page = await browser.newPage();<\/strong>\r\n<strong>    await page.goto(crawlerUrl, { waitUntil: 'networkidle0' });<\/strong>\r\n\r\n<strong>    const [crawlerUrls, content] = await page.evaluate(() =&gt; { \/\/ \u3053\u3053\u306f\u30d6\u30e9\u30a6\u30b6\u5185\u306e JavaScript<\/strong>\r\n\r\n<strong>        let urls = [];<\/strong>\r\n<strong>        document.querySelectorAll('a').forEach(link =&gt; {<\/strong>\r\n\r\n<strong>            const url = link.getAttribute('href');<\/strong>\r\n<strong>            urls.push(url);<\/strong>\r\n\r\n<strong>        });<\/strong>\r\n<strong>        const content = document.body.innerText;<\/strong>\r\n\r\n<strong>        return [urls, content];<\/strong>\r\n\r\n<strong>    })<\/strong>\r\n<strong>    const filteredCrawlerUrls = getTargetHostNameUrl(crawlerUrls);<\/strong>\r\n\r\n<strong>    \/\/ \u53d6\u5f97\u3057\u305f URL \u3092 DB \u3078\u4fdd\u5b58\u3059\u308b<\/strong>\r\n<strong>    await saveCrawlerUrls(filteredCrawlerUrls);<\/strong>\r\n\r\n<strong>    \/\/ \u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u30c1\u30a7\u30c3\u30af<\/strong>\r\n<strong>    const hasKeyword = content.includes(KEYWORD);<\/strong>\r\n<strong>    await saveHasKeyword(hasKeyword, crawlerUrl);<\/strong>\r\n\r\n<strong>    if(hasKeyword === true) {<\/strong>\r\n\r\n<strong>        console.log('\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\uff01');<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n<strong>    await browser.close();<\/strong>\r\n<strong>    exit();<\/strong>\r\n\r\n<strong>})();<\/strong><\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u5c11\u3057\u3081\u3093\u3069\u3046\u3068\u3044\u3046\u304b\u5384\u4ecb\u306a\u306e\u304c\u3001<code>async<\/code>\uff0f<code>await<\/code>\u90e8\u5206\u3058\u3083\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u610f\u5473\u3068\u3057\u3066\u306f\u3001\u300c<strong>\u975e\u540c\u671f\uff08async\uff09\u306e\u90e8\u5206\u304c\u5b8c\u4e86\u3059\u308b\u307e\u3067\u5f85\u3064\u3088\uff08await\uff09\ud83d\udc4d<\/strong>\u300d\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u975e\u540c\u671f\u3067\u3042\u3063\u3066\u3082\u9806\u756a\u306b\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3057\u3064\u3064\u8fd4\u308a\u5024\u304c\u53d6\u5f97\u3067\u304d\u308b\u306e\u3067\u30b3\u30fc\u30c9\u304c\u66f8\u304d\u3084\u3059\u304f\u306a\u308b\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001\u79c1\u306f\u901a\u5e38\u306e<code>JavaScript<\/code>\u3067\u306f\u305d\u308c\u307b\u3069\u3001<code>async<\/code>\uff0f<code>await<\/code>\u306f\u4f7f\u3044\u307e\u305b\u3093\u304c\u3001\u300c<strong>MySQL\u3078\u306e\u63a5\u7d9a<\/strong>\u300d\u3084\u300c<strong>\u30d8\u30c3\u30c9\u30ec\u30b9 Chrome\u306e\u90e8\u5206<\/strong>\u300d\u304c\u975e\u540c\u671f\u306b\u306a\u3063\u3066\u3044\u308b\u95a2\u4fc2\u3067\u63a1\u7528\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u307e\u305f\u3001\u5927\u304d\u304f\u4ee5\u4e0b\u306e\u30d6\u30ed\u30c3\u30af\u3067\u56f2\u3093\u3067\u3044\u308b\u306e\u306f\u3001\u300c<strong>await \u306f\u3001async \u95a2\u6570\u306e\u4e2d\u3067\u3057\u304b\u4f7f\u3048\u306a\u3044<\/strong>\u300d\u3068\u3044\u3046\u5236\u7d04\u304c\u3042\u308b\u305f\u3081\u3067\u3059\u3002<\/p>\n<pre><strong>(async() =&gt; { ... })();<\/strong><\/pre>\n<p>\u3053\u306e\u8fba\u308a\u306f\u6982\u5ff5\u7684\u306b\u5c11\u3057\u96e3\u3057\u3044\u304b\u3082\u3067\u3059\u306d\u2026\ud83d\ude05<\/p>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u2757<\/p>\n<p>\u30bf\u30fc\u30df\u30ca\u30eb\u304b\u3089\u30b3\u30fc\u30c9\u306e\u3042\u308b\u5834\u6240\u306b\u79fb\u52d5\u3057\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u4f55\u5ea6\u304b\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre><strong>node crawler.js<\/strong><\/pre>\n<p>\u203b \u3054\u6ce8\u610f\uff1a \u74b0\u5883\u306b\u3088\u3063\u3066\u306f\u300cnode\u300d\u3067\u306f\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u300c\u653f\u5e9c\u300d\u3068\u3044\u3046\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u30cb\u30e5\u30fc\u30b9\u306f\u5b58\u5728\u3057\u3066\u3044\u308b\u3067\u3057\u3087\u3046\u304b\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306f\u3053\u3046\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10773\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/07\/headless_chrome_crawler_2.png\" alt=\"\" width=\"301\" height=\"322\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/07\/headless_chrome_crawler_2.png 301w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/07\/headless_chrome_crawler_2-280x300.png 280w\" sizes=\"auto, (max-width: 301px) 100vw, 301px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u30da\u30fc\u30b8\u3068\u305d\u3046\u3067\u306a\u3044\u30da\u30fc\u30b8\u304c\u5b58\u5728\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u6210\u529f\u3067\u3059\ud83d\ude0a\u2728\uff08\u5b9f\u969b\u306b<code>URL<\/code>\u3092\u78ba\u8a8d\u3057\u305f\u3068\u3053\u308d\u304d\u3061\u3093\u3068\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3057\u305f\uff09<\/p>\n<h1>\u4f01\u696d\u69d8\u3078\u306e\u3054\u63d0\u6848<\/h1>\n<p>\u4eca\u56de\u306e\u3088\u3046\u306a\u72ec\u81ea\u30af\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u3063\u3066\u304a\u304f\u3053\u3068\u3067\u3001\u300c<strong>\u60c5\u5831\u96c6\u3081<\/strong>\u300d\u306b\u5f79\u7acb\u3066\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u4f7f\u3044\u65b9\u306f\u3044\u304b\u304c\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<ul>\n<li>\u682a\u4fa1\u306b\u95a2\u9023\u304c\u3042\u308b\u3088\u3046\u306a\u6c7a\u7b97\u306e\u30cb\u30e5\u30fc\u30b9\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/li>\n<li>\u81ea\u5206\u306e\u696d\u754c\u306b\u95a2\u9023\u306e\u3042\u308b\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u8a18\u4e8b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3053\u3068\u3067\u30e9\u30a4\u30d0\u30eb\u4f1a\u793e\u306e\u52d5\u5411\u3092\u63a2\u308b<\/li>\n<li>\u7279\u5b9a\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u8a18\u4e8b\u306b\u8f09\u3063\u3066\u3044\u308b\u4f1a\u793e\u3078\u55b6\u696d\u3092\u304b\u3051\u305f\u308a\u3001\u81ea\u793e\u88fd\u54c1\u306e\u63d0\u6848\u3092\u3059\u308b<\/li>\n<\/ul>\n<p>\u306a\u306b\u3088\u308a\u3001\u4e00\u756a\u5927\u304d\u306a\u30e1\u30ea\u30c3\u30c8\u306f\u4e0a\u8a18\u306e\u3088\u3046\u306a\u4f5c\u696d\u3092\u300c<strong>\u5168\u81ea\u52d5\u3067\u7e70\u308a\u8fd4\u3057\u5b9f\u884c\u3067\u304d\u308b<\/strong>\u300d\u3068\u3044\u3046\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u7a7a\u3044\u305f\u6642\u9593\u306f\u3088\u308a\u30af\u30ea\u30a8\u30a4\u30c6\u30a3\u30d6\u306a\u4f5c\u696d\u306b\u3042\u3066\u3066\u3001\u305c\u3072\u696d\u7e3e\u3092\u4f38\u3070\u3059\u3053\u3068\u306b\u5f79\u7acb\u3066\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3053\u3046\u3044\u3063\u305f\u6a5f\u80fd\u3092\u3054\u5e0c\u671b\u3067\u3057\u305f\u3089\u3001\u304a\u6c17\u8efd\u306b\u3054\u9023\u7d61\u304f\u3060\u3055\u3044\u3002<br \/>\n\u304a\u5f85\u3061\u3057\u3066\u304a\u308a\u307e\u3059\u3002\ud83d\ude0a\u2728<\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u300c<strong>\u30d8\u30c3\u30c9\u30ec\u30b9 Chrome<\/strong>\u300d\u3092\u4f7f\u3063\u3066\u7279\u5b9a\u30b5\u30a4\u30c8\u306b\u7279\u5316\u3057\u305f\u30af\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u4f55\u6c17\u306b\u300c<code>JavaScript<\/code>\u3067\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3055\u308c\u305f\u3082\u306e\u3067\u3082<code>OK<\/code>\u300d\u3068\u3044\u3046\u306f\u5927\u304d\u306a\u30e1\u30ea\u30c3\u30c8\u3060\u3068\u8a00\u3063\u3066\u826f\u3044\u3093\u3058\u3083\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u3055\u3089\u306b\u3001\u30d6\u30e9\u30a6\u30b6\u5185\u306b\u30ab\u30b9\u30bf\u30e0\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u633f\u5165\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u3067\u3001\u901a\u5e38\u306f\u305d\u306e\u30b5\u30a4\u30c8\u3067\u306f\u3067\u304d\u306a\u3044\u52d5\u304d\u3092\u5f37\u5236\u7684\u306b\u5b9f\u884c\u3067\u304d\u3001\u30a2\u30a4\u30c7\u30a2\u6b21\u7b2c\u3067\u3044\u308d\u3044\u308d\u306a\u3053\u3068\u304c\u3067\u304d\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u3082\u30c1\u30e3\u30ec\u30f3\u30b8\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u2757<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3566 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1.png\" alt=\"\" width=\"306\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1.png 306w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1-287x300.png 287w\" sizes=\"auto, (max-width: 306px) 100vw, 306px\" \/>\u300c\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3055\u3093\u306b\u3044\u305f\u3060\u3044\u305f<br \/>\n\u30af\u30e9\u30d5\u30c8\u30d3\u30fc\u30eb\u304c\u307e\u308d\u3084\u304b\u3067<br \/>\n\u7f8e\u5473\u3057\u3044\u2757\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u3068\u3053\u308dLaravel\u3084Vue\u95a2\u9023\u306e\u8a18\u4e8b\u3070\u304b\u308a\u66f8\u3044\u3066\u3044\u305f\u306e\u3067\u3001\u305f\u307e\u306b\u306f\u300c\uff19\u56de\u30ab\u30ec\u30fc\u3060\u3063\u305f\u3089\u3001\u6b21\u306f\u30cf\u30e4\u30b7\u30e9\u30a4\u30b9\u300d\u7684\u306a\u6c17\u5206\u306b\u306a\u308a\u307e\u3057\u305f\u3002 \u305d\u3057\u3066\u3001\u3058\u3083\u3042 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=10768\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u30d8\u30c3\u30c9\u30ec\u30b9 Chrome \u3067\u7279\u5b9a\u30b5\u30a4\u30c8\u306e\u30af\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":10777,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[203],"tags":[],"class_list":["post-10768","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-node-js"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/10768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10768"}],"version-history":[{"count":6,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/10768\/revisions"}],"predecessor-version":[{"id":10776,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/10768\/revisions\/10776"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/10777"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}