2016-10-27 154 views
0

我发现了其他几个类似的问题,但他们都没有解决我需要解决的确切问题。我试图模拟鼠标点击,以获得滚动的整个结果(例如,从该站点:http://www.deadseascrolls.org.il/explore-the-archive/manuscript/4Q266-1)可见。我特别想在显示图像底部中心的“加载更多结果”项目上点击(但是由于网站的源代码,我认为这会变得更加困难)。我想单击它直到显示所有结果。我写了下面的AppleScript:点击Applescript/JavaScript网页上的按钮

on iaaScroll(myScroll) 
tell application "Safari" 
    activate 
    open location "http://www.deadseascrolls.org.il/explore-the-archive/manuscript/" & myScroll & "-1" as string 
    delay 2.0 
    do JavaScript "var myDIV = document.getElementById('loadmore').getElementsByTagName('span')[0]; myDIV.dispatchEvent(new MouseEvent('mousedown')); myDIV.dispatchEvent(new MouseEvent('mouseup'));" in document 1 
end tell 

末iaaScroll

我不能,不过,顺利拿到的JavaScript加载页面上所有的结果。我将如何成功地做到这一点?我不知道JavaScript,所以你的帮助非常感谢。

回答

0

这个脚本将启动该网站,点击“加载更多结果”一周时间..

tell application "Safari" 
    activate 
    set URL of document 1 to "http://www.deadseascrolls.org.il/explore-the-archive/manuscript/4Q266-1" 
    delay 3 
    do JavaScript "document.getElementById('loadmore').click();" in document 1 
end tell 

一旦该网页是open..This本身脚本点击“加载更多结果”一次。每一次运行该脚本

tell application "Safari" 
    activate 
    do JavaScript "document.getElementById('loadmore').click();" in document 1 
end tell 

或..既然你谈论的是一个特定的网页加载,最终的图像416 ..我在剧本中加入重复的语句,最终将加载该网站与所有显示的图像。 。您可能需要调整延迟值,但是在设置时现在,脚本可以在我的机器上完美运行

tell application "Safari" 
    activate 
    set URL of document 1 to "http://www.deadseascrolls.org.il/explore-the-archive/manuscript/4Q266-1" 
    delay 4 -- you may need to adjust your delay time to account for your browser speed 
    repeat 34 times -- adjust this number if there are more than 416 results 
     do JavaScript "document.getElementById('loadmore').click();" in document 1 
     delay 0.55 -- you may need to adjust your delay time to account for your browser speed 
    end repeat 
end tell 
+0

谢谢。我写了一个额外的JavaScript语句来获得innerHTML,并重复while user1628415