2016-10-27 4 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

을 나는, 그러나 성공적으로 자바 스크립트 페이지의 모든 결과를로드 할 수 없습니다. 어떻게 성공적으로이 작업을 수행 할 수 있습니까? 자바 스크립트를 모르므로 도움을 많이 주셨습니다. 해당 웹 페이지가되면

답변

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 자체 스크립트가 한 번 .. 각을 "부하 더 많은 결과보기"를 클릭합니다 시간 당신은 궁극적으로 표시되는 모든 이미지와 해당 웹 사이트를로드 할 얘기되는 특정 페이지가 궁극적으로 416 개 이미지를로드하기 때문에

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

또는 ..

은 .. 내가 스크립트에서 반복 문을 추가 한 스크립트를 실행합니다. 지연 값을 조정할 필요가있을 수 있지만 설정시 이제 스크립트가 내 컴퓨터에서 완벽하게 실행됩니다.

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

감사합니다. 나는 innerHTML을 얻기 위해 추가적인 자바 스크립트 문장을 썼고, user1628415

관련 문제