Extract a URL from a link and then download PDF it links to?

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Extract a URL from a link and then download PDF it links to?

by iMacroScripter on Fri May 05, 2017 11:23 am

iMacros: VERSION BUILD=8970419
OS: Windows 7
Browser: Firefox 47
Demos Work: Yes
VBS Scripting: Yes
URL: N/A
IMacros work on other version: N/A

I am trying to extract a URL from a link, and then tell iMacros to "download"/"save target as" the URL it extracts, and download the file from that URL.
Specifically, I am trying to retrieve the second link (the PDF file), named "vxlr0031_16411196.PDF":
Image

Specifically, when I use the "record" feature in iMacros and click on the link it retrieves the link as:
Code: Select all
TAG POS=1 TYPE=A ATTR=ID:URL$1
TAB T=2

(Where the second line has the PDF opening in the second tab as an opened PDF file)

But when I mouse over the link it retrieves the "name" of the link as: "URLID" and the actual URL as: "https://ps-sis-sa90.vccs.edu/psreports/ps/13897007/vxlr0031_16411196.PDF".

Using the code:
Code: Select all
TAG POS=1 TYPE=A ATTR=ID:URL$1 EXTRACT=HREF


Allows me to extract the actual URL as: "https://ps-sis-sa90.vccs.edu/psreports/ps/13897007/vxlr0031_16411196.PDF"

But what code do I use to tell iMacros to:
1) take that actual URL it extracts and
2) use that actual URL it extracts, and then "download"/"save target as" that actual URL, so that the PDF that actual URL links to (since the actual URL ends in ".PDF") actually downloads the PDF file?
iMacroScripter
 
Posts: 1
Joined: Thu Apr 27, 2017 8:10 am

Re: Extract a URL from a link and then download PDF it links

by chivracq on Fri May 05, 2017 1:50 pm

iMacroScripter wrote:
Code: Select all
iMacros: VERSION BUILD=8970419
OS: Windows 7
Browser: Firefox 47
Demos Work: Yes
VBS Scripting: Yes
URL: N/A
IMacros work on other version: N/A


I am trying to extract a URL from a link, and then tell iMacros to "download"/"save target as" the URL it extracts, and download the file from that URL.
Specifically, I am trying to retrieve the second link (the PDF file), named "vxlr0031_16411196.PDF":
Image

Specifically, when I use the "record" feature in iMacros and click on the link it retrieves the link as:
Code: Select all
TAG POS=1 TYPE=A ATTR=ID:URL$1
TAB T=2

(Where the second line has the PDF opening in the second tab as an opened PDF file)

But when I mouse over the link it retrieves the "name" of the link as: "URLID" and the actual URL as: "https://ps-sis-sa90.vccs.edu/psreports/ps/13897007/vxlr0031_16411196.PDF".

Using the code:
Code: Select all
TAG POS=1 TYPE=A ATTR=ID:URL$1 EXTRACT=HREF


Allows me to extract the actual URL as: "https://ps-sis-sa90.vccs.edu/psreports/ps/13897007/vxlr0031_16411196.PDF"

But what code do I use to tell iMacros to:
1) take that actual URL it extracts and
2) use that actual URL it extracts, and then "download"/"save target as" that actual URL, so that the PDF that actual URL links to (since the actual URL ends in ".PDF") actually downloads the PDF file?

I would think the 'SAVETARGETAS' 'EVENT' Parameter is what you want..., try this:
Code: Select all
ONDOWNLOAD FOLDER=* FILE=* WAIT=YES
TAG POS=1 TYPE=A ATTR=ID:URL$1 CONTENT=EVENT:SAVETARGETAS


Another Solution could be to use the 'SAVEITEM' Command in your 2nd Tab:
Code: Select all
TAG POS=1 TYPE=A ATTR=ID:URL$1
TAB T=2
ONDOWNLOAD FOLDER=* FILE=* WAIT=YES
SAVEITEM
WAIT SECONDS=1


>

(No need to open Duplicate Threads btw when you want to start a Thread, but I guess this was an involuntary Mistake... (I've deleted your Duplicate...))
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to Data Extraction and Web Screen Scraping

Who is online

Users browsing this forum: Google [Bot] and 2 guests

-->