File tree 2 files changed +12
-27
lines changed
2 files changed +12
-27
lines changed Original file line number Diff line number Diff line change @@ -22,17 +22,17 @@ yarn add @philippdormann/mensamax-api
22
22
```
23
23
#### ts/ module imports
24
24
``` ts
25
- import { fetcher , parser } from ' @philippdormann/mensamax-api' ;
26
- const html = await fetcher ({ p: ' FO111' , e: ' herz' });
25
+ import { fetchHTML , parser } from ' @philippdormann/mensamax-api' ;
26
+ const html = await fetchHTML ({ p: ' FO111' , e: ' herz' , kw: 15 });
27
27
const parsed = await parser (html );
28
28
console .log (parsed );
29
29
```
30
30
#### CommonJS imports
31
31
``` js
32
- const { fetcher , parser } = require (' @philippdormann/mensamax-api' );
33
- (async function () {
32
+ const { fetchHTML , parser } = require (' @philippdormann/mensamax-api' );
33
+ (async function () {
34
34
try {
35
- const html = await fetcher ({ p: ' FO111' , e: ' herz' });
35
+ const html = await fetchHTML ({ p: ' FO111' , e: ' herz' , kw : 15 });
36
36
const parsed = await parser (html);
37
37
console .log (parsed);
38
38
} catch (e) {
Original file line number Diff line number Diff line change 1
1
const { fetchHTML } = require ( './api/fetcher' ) ;
2
- const { parser, getMensaPlanHTML } = require ( './main' ) ;
3
- const fs = require ( 'fs' ) ;
4
-
5
- ( async function test ( ) {
2
+ const { parser } = require ( './main' ) ;
3
+ ( async function ( ) {
6
4
try {
7
- const html = await fetchHTML ( {
8
- p : 'FO111' ,
9
- e : 'herz' ,
10
- kw : 17 ,
11
- provider : 'mensadigital.de'
12
- } ) ;
13
- if ( html . includes ( 'Klicken Sie hier um sich neu anzumelden' ) ) {
14
- console . log ( 'FAIL' ) ;
15
- } else {
16
- console . log ( 'SUCCESS' ) ;
17
- }
18
- // console.log(html);
19
- fs . writeFileSync ( './out.html' , html ) ;
20
- // const parsed = await parser(html);
21
- // console.log(parsed);
22
- // fs.writeFileSync('./out.json', JSON.stringify(parsed));
23
- } catch ( error ) {
24
- console . log ( error ) ;
5
+ const html = await fetchHTML ( { p : 'FO111' , e : 'herz' , kw : 15 } ) ;
6
+ const parsed = await parser ( html ) ;
7
+ console . log ( parsed ) ;
8
+ } catch ( e ) {
9
+ console . log ( e ) ;
25
10
}
26
11
} ) ( ) ;
You can’t perform that action at this time.
0 commit comments