File tree Expand file tree Collapse file tree
apps/functions/scraper/src/restaurants Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { RestaurantMetaProps } from '@devolunch/shared' ;
2+ import { Page } from 'puppeteer' ;
3+
4+ export const meta : RestaurantMetaProps = {
5+ title : 'Two Forks' ,
6+ url : 'https://www.twoforks.se/lunch' ,
7+ imageUrl :
8+ 'https://images.squarespace-cdn.com/content/v1/5c6fc5858155121249a4c49f/d9867018-aaa7-4d7c-8a5b-b5f666277406/%C2%A9jensnordstromtwoforks0027.jpg' ,
9+ googleMapsUrl : 'https://maps.app.goo.gl/GKATv8jSGjbAKfYt5' ,
10+ coordinate : {
11+ lat : 55.6073278 ,
12+ lon : 12.9920499 ,
13+ } ,
14+ } ;
15+
16+ export const browserScrapeFunction = ( page : Page ) =>
17+ page . evaluate ( ( ) => {
18+ const nbrs = [ 1 , 2 , 3 ] as const ;
19+ const types = { 1 : 'vegan' , 2 : 'vegan' , 3 : 'meat' } as const ;
20+
21+ return nbrs . map ( ( nbr ) => {
22+ const header = [ ...document . querySelectorAll ( 'h2' ) ] . find ( ( h ) => h . innerText === `NO. ${ nbr } ` ) ;
23+ const title = ( header ?. nextElementSibling as HTMLParagraphElement ) ?. innerText . trim ( ) ;
24+
25+ return { type : types [ nbr ] , title } ;
26+ } ) ;
27+ } ) ;
You can’t perform that action at this time.
0 commit comments