2013-05-17 42 views
0

我有大約1000個鏈接到遠程PDF文件的URL,我需要確定哪些可以通過Safari搜索,哪些不可以。我有我的腳本循環,並在Safari中打開URL,但我堅持在最後2步以下。使用Safari瀏覽器搜索PDFs使用Applescript

有人可以幫忙嗎?由於

的腳本需要:

對於每個網址:

告訴Safari瀏覽器

  1. 打開一個給定的URL(在這種情況下,遠程PDF)
  2. 搜索PDF對於字符「a」使用在右擊時彈出的查找,而不是Apple F enter image description here

  3. 寫的搜索結果到一個文件

    set urlList to {"http://pricelist.list.com/pricelists/A/AEA_11-15-12.pdf", "http://pricelist.list.com/pricelists/A/API_1608_04-05-13.pdf", "http://pricelist.list.com/pricelists/A/Access_02-01-12.pdf", "http://pricelist.list.com/pricelists/A/Allparts_Retail_01-01-11.pdf"} 
        set numURLs to (count urlList) 
        repeat with i from 1 to (numURLs) 
    
    set theURL to (item i of urlList) 
    tell application "Safari" 
        open location theURL 
        activate 
        --Perform search 
        --Write results to file 
    end tell 
    tell application "System Events" 
        tell process "Safari" 
         click menu item "Close Other Tabs" of menu "File" of menu bar 1 
        end tell 
    end tell 
    delay 5 
    

    末重複

回答

0

這可能是更容易下載的PDF文件,並使用shell腳本:

brew install poppler wget parallel 
cat ~/Documents/urls.txt | parallel -P8 wget 
for f in *.pdf; do [[ $(pdffonts -- "$f" 2> /dev/null | wc -l) -eq 2 ]] && printf %s\\n "$f"; done 

pdffonts打印兩行爲沒有嵌入字體的掃描PDF輸出。見How do I determine programmatically if a PDF is searchable?

相關問題