File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
15
15
unit : 'seconds' , // seconds, m: minutes, h: hours
16
16
value : 5
17
17
}
18
- let url = 'https://www.currys.co.uk/gbuk/gaming/console -gaming/controllers/microsoft-xbox-wireless-controller-robot-white-10211569 -pdt.html'
18
+ let url = 'https://www.currys.co.uk/gbuk/gaming/pc -gaming/gaming-laptops/alienware-m17-r2-17-3-gaming-laptop-intel-core-i7-rtx-2070-1-tb-ssd-10219996 -pdt.html'
19
19
currys ( url , interval ) ;
20
20
}
21
21
@@ -56,11 +56,15 @@ export default async function currys(url, interval) {
56
56
57
57
let parser = new DomParser ( ) ;
58
58
let doc = parser . parseFromString ( html , 'text/html' ) ;
59
- let title = doc . getElementsByClassName ( 'product_name' )
60
- let inventory = doc . getElementsByClassName ( 'space-b center' )
59
+ let title = doc . getElementsByClassName ( 'product_name' )
60
+ let inventory = doc . getElementsByClassName ( 'space-b center' )
61
61
let image = doc . getElementsByTagName ( 'meta' ) . filter ( meta => meta . getAttribute ( 'property' ) == 'og:image' )
62
62
63
63
if ( title . length > 0 ) title = title [ 0 ] . textContent
64
+ else {
65
+ title = doc . getElementsByTagName ( 'meta' ) . filter ( meta => meta . getAttribute ( 'property' ) == 'og:title' )
66
+ if ( title . length > 0 ) title = title [ 0 ] . getAttribute ( 'content' )
67
+ }
64
68
if ( inventory . length > 0 ) {
65
69
inventory = inventory [ 0 ] . getAttribute ( 'data-button-label' )
66
70
if ( inventory . length > 0 ) inventory = inventory . slice ( 29 , 42 )
You can’t perform that action at this time.
0 commit comments