Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #100 from BenShelton/develop
Browse files Browse the repository at this point in the history
Fix Scraper Race Condition
  • Loading branch information
BenShelton authored Nov 20, 2019
2 parents 7d68aff + cf914fd commit f309c63
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions database/scraper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const LANGUAGE_OPTIONS: { [key in Languages]: ILanguageOptions } = {
months: ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'],
addressConstructor: async (date) => {
// this WOL url, although consistent, seemed to stop being updated in 2020
const addresses = ['https://wol.jw.org/en/wol/dt/r1/lp-e/' + date.replace(/-/g, '/')]
let address: string = 'https://wol.jw.org/en/wol/dt/r1/lp-e/' + date.replace(/-/g, '/')
// alternative scraping of main site by going to the consistent workbook page and extracting the link
try {
const [sY, sM, sD] = date.split('-').map(Number)
Expand All @@ -39,12 +39,12 @@ const LANGUAGE_OPTIONS: { [key in Languages]: ILanguageOptions } = {
links.each((i, el) => {
const text = $(el).text().trim().toLowerCase()
if (regex.test(text)) {
addresses.push('https://www.jw.org' + $(el).attr('href'))
address = 'https://www.jw.org' + $(el).attr('href')
return false
}
})
} catch {}
return addresses
return [address]
},
inherit: [],
cbsTitle: 'Congregation Bible Study',
Expand Down

0 comments on commit f309c63

Please sign in to comment.