Applescript - 检查URL列表的页面内容是否包含THIS_TEXT |输出所有这些URL

时间:2018-05-02 18:39:10

标签: shell applescript

尝试以下操作:

  1. 我的脚本返回约。 20个URL作为变量Single_URLs
  2. 检查这些网址是否包含THIS_TEXT
  3. 保持网址包含THIS_TEXT
  4. 从结果中删除其他网址
  5. Pure Applescript或Shell。

    我的示例脚本只是检查提供的URL是否包含THIS_TEXT,因为我现在还没有进一步。

    --Open Pages
    set site_url to "https://teespring.com/shop/CLASSIC-DODGE-CHARGER-MOP?aid=marketplace&tsmac=marketplace&tsmic=search#pid=212&cid=5819&sid=front"
    tell application "Safari"
        activate
        open location site_url
    end tell
    
    -- wait until page loaded
    property testingString : "CLASSIC DODGE CHARGER" --Text on website to look for
    
    set pageLoaded to false
    tell application "Safari"
        repeat while pageLoaded is false
            set readyState to (do JavaScript "document.readyState" in document 1)
            set pageText to text of document 1
    
            if (readyState is "complete") and (pageText contains testingString) then set pageLoaded to true
            delay 0.2
        end repeat
    end tell
    
    -- get number of links
    set theLinks to {}
    tell application "Safari" to set num_links to (do JavaScript "document.links.length" in document 1)
    set linkCounter to num_links - 1
    -- retrieve the links
    repeat with i from 0 to linkCounter
        tell application "Safari" to set end of theLinks to do JavaScript "document.links[" & i & "].href" in document 1
    
    
    end repeat
    theLinks
    set nonExcludedURLs to {}
    pageLoaded
    

    这是一个慈善项目,旨在帮助艺术家不被欺骗。非常欢迎每一个帮助,谢谢。

1 个答案:

答案 0 :(得分:1)

这是一个用AppleScript执行此操作的脚本:

let express = require('express')
let cookieParser = require('cookie-parser')
let bodyParser = require('body-parser')
let app = express()

app.use(logger('dev'))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(cookieParser())
app.use(express.static(path.join(__dirname, 'public')))
... below code just routing code...

我希望这会有所帮助。