Recipe reader
A recipe tells the crawler what to fetch and how to read it. The package has two recipes: readVenue reads the opening hours of a venue, and readProduct reads a product page. This tool starts their readers on one page. Paste the HTML of a page, or select an example.
The tool uses the real code of polite-crawler, compiled into this page: extractPage, venueReadingsOf, productOf, pickProduct, readAmount, locate and compareHours. It sends no request, and your HTML stays in your browser.
venueReadingsOf reads the JSON-LD records of a venue and the text of the page. Each reading has a rank: JSON-LD is 0, a text below an hours heading is 1, and a different schedule is 4.
readVenue names these days in disagree. The application decides which reading is true.Tue–Sun 07:00–15:00
From the JSON-LD of the page, at jsonld[0]. It is not in the visible text, so a citation names the record.
Mon closed; Tue–Sat 07:00–14:00; Sun 08:00–13:00
Tuesday to Saturday: 7 am to 2 pm Sunday: 8 am to 1 pm Closed on Mondays
✓ verify finds this quote at the characters 98 to 170 of the text.
Sat–Sun 10:00–13:00
Sat-Sun 10-1
✓ verify finds this quote at the characters 178 to 190 of the text.
- Phone
- +1-555-0100
- Menu links
- https://forno-esempio.example/menu
Compare with the hours that you keep
compareHours compares the kept hours with one reading, day by day. Select the reading.
compareHours gives same: each day that the two weeks state is the same.
| Day | Kept | Reading 1 | Result |
|---|---|---|---|
| Mon | not stated | not stated | not stated |
| Tue | 07:00–15:00 | 07:00–15:00 | same |
| Wed | 07:00–15:00 | 07:00–15:00 | same |
| Thu | 07:00–15:00 | 07:00–15:00 | same |
| Fri | 07:00–15:00 | 07:00–15:00 | same |
| Sat | 07:00–15:00 | 07:00–15:00 | same |
| Sun | 07:00–15:00 | 07:00–15:00 | same |
A change is not a fact yet. Confirm it with a second reading, as a watch does.
What the venue reader reads
Section titled “What the venue reader reads”- The JSON-LD of a venue. A record of a venue type (
Restaurant,Bakery,Storeand more) can giveopeningHoursSpecificationoropeningHours. Such a reading has the rank 0. - The text of the page. The hours parser reads the text. A reading below a heading, for example “Hours”, has the rank 1. A different schedule, for example a brunch or a happy hour, has the rank 4.
- A quote for each reading of the text. The
rawtext of a reading is a quote thatverifyfinds in the stored page. A citation can thus point at the exact words. - One location of a group. A page can list more than one location. Then the reader reads only the location that matches
location, by its street address or its position. With nolocation, it reads none of them, and a note says so.
readVenue also fetches the pages of the site that most likely hold hours, and it reads each one the same way. It gives the best reading, the best reading of the site with no guess (from_site), and the days where two readings disagree.
What the product reader reads
Section titled “What the product reader reads”- The product of the page, not a related product. The reader takes the Product record whose
urlor@idnames the page. With no such record, it takes the largest record with offers. A related product with many reviews can be larger, so the URL comes first. Select the product example to see it. - The price as money. A price is an amount and an ISO 4217 currency, for example
{ amount: 21, currency: "EUR", raw: "21,00" }.readAmountreads21,00,1.299,00and$19.99. A list price or a struck-through price is not the price. - The variants.
priceandprice_togive the range of the variants. A URL with?variant=,skuorgtinnames one variant, andvariantgives its price and availability. - A wall is a clean stop. A shop that refuses the crawler, or sends a bot check, gives
wall: trueand a note. The crawler does not try a different identity.
Compare with the hours that you keep
Section titled “Compare with the hours that you keep”An application keeps the hours of a venue. compareHours(kept, reading) compares a new reading with them, day by day:
- same: each day that the two weeks state has the same intervals.
- changed: a day of the two weeks is different. The result names the days.
- new: the application keeps no hours for the venue.
A day that only the reading states is new. It is not a change. A change is not a fact yet: confirm it with a second reading, as a watch does. The first example shows why. Its JSON-LD gives the old hours, and its text gives the new hours, so the reading of the site says “same” and disagree names six days.