Intern 1, second solution. This version avoids opening all the download windows. Instead it extracts each file URL and then downloads them using the OPEN command. That works well. This is our recommended solution.
Video (First method 1A above, then the URL extraction method at t=58s):
For all solutions remember to set PDF to automatic download in the browser settings:
{
"Name": "Get All PDF - Intern1 - Extract URL ",
"CreationDate": "2024-4-6",
"Commands": [
{
"Command": "open",
"Target": "https://www.elegislation.gov.hk/index/chapternumber?TYPE=1&TYPE=2&TYPE=3&LANGUAGE=E",
"Value": "",
"Description": ""
},
{
"Command": "label",
"Target": "Repeat",
"Value": "",
"Description": ""
},
{
"Command": "store",
"Target": "1",
"Value": "Global_i",
"Description": ""
},
{
"Command": "executeScript",
"Target": "return parseInt(${Global_i})",
"Value": "Global_i",
"Description": ""
},
{
"Command": "storeXpathCount",
"Target": "xpath=//*[@id=\"CHAPTER_NO_INDEX_GRID\"]/div[2]/table/tbody/tr",
"Value": "Global_max_rows",
"Description": ""
},
{
"Command": "while",
"Target": "(${Global_i} < ${Global_max_rows})",
"Value": "",
"Description": ""
},
{
"Command": "echo",
"Target": "Counter is ${Global_I}",
"Value": "",
"Description": ""
},
{
"Command": "comment",
"Target": "store // xpath=//*[@id=\"CHAPTER_NO_INDEX_GRID\"]/div[2]/table/tbody/tr[${Global_i}]/td[3]/div/div/div/a/img",
"Value": "Global_xpath",
"Description": ""
},
{
"Command": "storeAttribute",
"Target": "xpath=(//*[@id=\"CHAPTER_NO_INDEX_GRID\"]/div[2]/table/tbody/tr[${Global_i}]/td[3]/div/div/div/a)@href",
"Value": "Global_URL",
"Description": ""
},
{
"Command": "store",
"Target": "https://www.elegislation.gov.hk",
"Value": "Global_Initial_URL",
"Description": ""
},
{
"Command": "store",
"Target": "${Global_Initial_URL}${Global_URL}",
"Value": "Global_download_URL",
"Description": ""
},
{
"Command": "onError",
"Target": "#goto",
"Value": "Next",
"Description": ""
},
{
"Command": "open",
"Target": "${Global_download_URL}",
"Value": "",
"Description": ""
},
{
"Command": "label",
"Target": "Next",
"Value": "",
"Description": ""
},
{
"Command": "comment",
"Target": "click // ${Global_xpath}",
"Value": "",
"Description": ""
},
{
"Command": "executeScript",
"Target": "return parseInt(${Global_i}) + 1",
"Value": "Global_i",
"Description": ""
},
{
"Command": "end",
"Target": "",
"Value": "",
"Description": ""
},
{
"Command": "onError",
"Target": "#goto",
"Value": "Complete",
"Description": ""
},
{
"Command": "click",
"Target": "xpath=//*[@id=\"CHAPTER_NO_INDEX_GRID\"]/div/a[5]/span",
"Value": "",
"Targets": [
"xpath=//*[@id=\"CHAPTER_NO_INDEX_GRID\"]/div/a[5]/span",
"xpath=//a[5]/span",
"css=#CHAPTER_NO_INDEX_GRID > div:nth-child(1) > a.grid-link.grid-page.grid-page-next > span:nth-child(1)"
],
"Description": ""
},
{
"Command": "label",
"Target": "Complete",
"Value": "",
"Description": ""
},
{
"Command": "selectWindow",
"Target": "tab=0",
"Value": "",
"Description": ""
},
{
"Command": "selectWindow",
"Target": "TAB=CLOSEALLOTHER",
"Value": "",
"Description": ""
}
]
}