Downloading PDF from link in a RSS-feed

Just butting in with my approach as the create PDF option was a bit slow here …

tell application id "DNtp"
	set od to AppleScript's text item delimiters
	if (selected records) is {} then return
	repeat with theArticle in (selected records whose (type is html))
		set theURL to (URL of theArticle) as string
		set theSource to (download markup from theURL)
		set pdfLinks to (get links of theSource base URL theURL type "PDF")
		if pdfLinks is not {} then
			repeat with thePDF in pdfLinks
				set AppleScript's text item delimiters to "/"
				set pdfName to last text item of thePDF
				set AppleScript's text item delimiters to od
				set pdfData to (download URL thePDF)
				set newPDF to create record with {name:pdfName, type:PDF document} in incoming group
				set data of newPDF to pdfData
			end repeat
		end if
	end repeat
end tell
2 Likes

That’s what I thought about, too. But as the data returned by downloadURL is not usable in JXA…