Professional Documents
Culture Documents
Bible Api IV
Bible Api IV
function verify_scrapy_folders {
param(
$bible_name,
$scrapy_date,
$scrapy_storange_path
)
if (-not(Test-path $storange_current_path)) {
mkdir $storange_current_path
}
else {
rmdir -r $storange_current_path
mkdir $storange_current_path
}
function get_credentials {
param($credentials_path)
try {
$content = $(Get-Content $credentials_path).split("=")
$h = @{$content[0]=$content[-1]}
return $h
} catch {
return $false
function verify_existing_bible_id {
param(
$h,
$base_url,
$pt_bible_id,
$bible_name_pt
)
try {
$r = Invoke-WebRequest -Uri $url -Headers $h -UseBasicParsing
$pt_bible_id = $bible.id
$bible_name = $bible.nameLocal.ToLower().trim().replace(' ', '_')
return $pt_bible_id, $bible_name
} catch {
$url = $base_url + "/bibles"
}
}
# IF TRY AND CATCH ERROR, RETURN HERE
}
function get_chapter_content {
param(
$h,
$base_url,
$chapter_id,
$pt_bible_id
)
return $chapter_content.content
function get_all_books {
param(
$h,
$base_url,
$pt_bible_id
)
return $book_list
$pt_bible_id = "d63894c8d9a7a503-01"
$bible_name_pt = "biblia_livre_para_todos"
$base_url = "https://api.scripture.api.bible/v1"
if (-not $h) {
Add-Content -Path $scrapy_storange_log_path `
-Value "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") | [ERROR] |
INVALID CREDENTIALS PATH"
exit
# VERIFY PT BIBLE
$pt_bible_id, $bible_name = verify_existing_bible_id -h $h -base_url $base_url `
-pt_bible_id $pt_bible_id -
bible_name_pt $bible_name_pt
$storange_current_path = $storange_current_path + "\" + $bible_name
if (-not(Test-path $storange_book_path)) {
mkdir $storange_book_path
}