On May 28, 2012, at 20:31, Manuel wrote:
Tonight, I have tried with text item delimiters to extract the links from this webpage
...
When you click in Aida 10x01, Safari downloads a .torrent file of the episode.
______________________________________________________________________
Hey Manuel,
So. If I understand correctly you want to grab all the links of the torrent files.
It's easier to do that directly than to parse the source.
The output of the handler is a list of URLs. From there you can iterate through and download them with Safari, or a better choice would be Progressive Downloader (freeware) or Leech (shareware) - both are scriptable.
If you need help with that let me know.
--
Best Regards,
Chris
------------------------------------------------------------------------------------------------
--ยป safari_links()
------------------------------------------------------------------------------------------------
-- Modified: 2010-12-30 : 01:00
-- Description: Get Links from Safari Using _javascript_ and a Regular _expression_
------------------------------------------------------------------------------------------------
on safari_links(regexStr, tagName, tagType)
set js to "function in_array (array, item) {
for (var i=0; i < array.length; i++) {
if ( array[i] == item ) {
return true;}}
return false;}
var a_tags = document.getElementsByTagName('" & tagName & "');
var href_array = new Array();
var reg = new RegExp(/" & regexStr & "/i);
for (var i=0; i < a_tags.length; i++) {
var href = "" style="font: 14.0px Verdana; color: #000000"> & tagType & ";
if ( reg.test(href)) {
if ( !in_array(href_array, href)) {
href_array.push(href);}}}
href_array;"
try
tell application "Safari" to set linkList to do _javascript_ js in document 1
on error
set linkList to {}
end try
return linkList
end safari_links
------------------------------------------------------------------------------------------------
set regexStr to "download"
set linkList to safari_links(regexStr, "*", "href")