Skip to content

Commit 669ccc9

Browse files
author
Drew McMillan
authored
Merge pull request #1 from drewmcmillan/AddUserAgent
Add user agent
2 parents e6a1c04 + 548d4ba commit 669ccc9

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ where `light-mc-crawler-config.json` looks something like this:
1818
"limit": "/music/",
1919
"httpsOnly": true,
2020
"showHttpLinksDuring": false,
21-
"showHttpLinksAfter": true
21+
"showHttpLinksAfter": true,
22+
"userAgent": "light-mc-crawler Mixed Content Crawler"
2223
}
2324
```
2425
This will crawl `https://www.example.com` and any pages coming off it with `/music/` in the url.

example.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"limit": "/music/",
66
"httpsOnly": true,
77
"showHttpLinksDuring": false,
8-
"showHttpLinksAfter": true
8+
"showHttpLinksAfter": true,
9+
"userAgent": "light-mc-crawler Mixed Content Crawler"
910
}

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = (options) => {
2828
crawler.respectRobotsTxt = false
2929
crawler.parseHTMLComments = false
3030
crawler.parseScriptTags = false
31+
crawler.userAgent = options.userAgent || "light-mc-crawler Mixed Content Crawler"
3132
crawler.maxDepth = config.maxDepth || 1
3233

3334

@@ -99,6 +100,7 @@ function runLighthouse (url, config, callback) {
99100
stats.pageCount++
100101
var mixedContent = require.resolve('lighthouse/lighthouse-core/config/mixed-content.js')
101102
var chromeFlags = config.chromeFlags || '--headless --disable-gpu';
103+
var userAgent = config.userAgent || 'light-mc-crawler Mixed Content Crawler'
102104
const args = [
103105
url,
104106
'--output=json',
@@ -107,7 +109,7 @@ function runLighthouse (url, config, callback) {
107109
'--disable-cpu-throttling',
108110
'--disable-storage-reset',
109111
'--disable-network-throttling',
110-
'--chrome-flags=' + chromeFlags,
112+
'--chrome-flags=' + chromeFlags + '--user-agent=' + userAgent,
111113
`--config-path=${mixedContent}`
112114
]
113115

0 commit comments

Comments
 (0)