Shell Scriptで6/1 OSC19do 大懇親会の会場を御案内します

Shell Scriptで6/1 OSC19do 大懇親会の会場を御案内します

Selenium WebDriverはShell Scriptでも使用可能です。HTTPieとjqを組み合わせて実装したので、その方法を説明し、デモとして題名通りの事をいたします。

Ee4c337fbe0db506f2fa17568ba3c7c8?s=128

東平洋史

May 05, 2019
Tweet

Transcript

  1. Shell Script 6/1 OSC19do     

  2.    

  3.  ?

  4.    

  5. None
  6. Shell Script 

  7.  !+),$ )&1.,! 1.  2. Web-0%' 3. GoogleOSC19do $

    4. Connpass!/2($ 5. $&1*& 6.  $$&1*& 7.  #" 8. 
  8.  • Bash – Linux, MacOS, Windows Subsystem for Linux

    (,FreeBSD, …) • Google Chrome • Google Chrome Driver https://sites.google.com/a/chromium.org/chromedriver/ • HTTPie (cURL ) https://github.com/jakubroztocil/httpie • jq (JSON  sed ) https://stedolan.github.io/jq/download/
  9.  HTTP  (JSON) HTTP (JSON) httpie  Chrome Driver

      
  10. HTTPie: a CLI, cURL-like tool for humans • https://github.com/jakubroztocil/httpie 

    HTTPie (pronounced aitch-tee-tee-pie) is a command line HTTP client. Its goal is to make CLI interaction with web services as human- friendly as possible. It provides a simple http command that allows for sending arbitrary HTTP requests using a simple and natural syntax, and displays colorized output. HTTPie can be used for testing, debugging, and generally interacting with HTTP servers.
  11. HTTPie  http [flags] [METHOD] URL [ITEM [ITEM]] ↓ RESPONSE=¥

    $(echo ‘(JSON)’ | ¥ http  APIURL ) API  https://w3c.github.io/webdriver/webdriver-spec.html http 
  12. Selenium WebDriverAPI ( ) +#%( URI&0)/1' *0( POST /session "%!,0

     POST /session/{session id}/url URL  GET /session/{session id}/title $'. POST /session/{session id}/element   POST /session/{session id} /element/{element id}/sendKeys   1  POST /session/{session id} /element/{element id}/click   -% https://w3c.github.io/webdriver/webdriver-spec.html 
  13. (Chrome Driver ) pkill chromedriver chromedriver &

  14. Google Chrome  RESPONSE=$(http POST localhost:9515/session ¥ desiredCapabilities:='{}’ ¥ requiredCapabilities:='{}')

    #  ID SESSION_ID=$(echo ${RESPONSE} | jq -r .sessionId)
  15. http  { "sessionId": "8dc5eab177a254e8f36b4eceb8b2f427", "status": 0, () }

  16. Google http POST ¥ localhost:9515/session/${SESSION_ID}/url ¥ url= http://www.google.co.jp/

  17. Google   RESPONSE=$(http POST ¥ localhost:9515/session/${SESSION_ID}/element ¥ using=name value=q)

    # ELEMENT_ID ID  ELEMENT_ID=$(echo ${RESPONSE} | ¥ jq .value | jq -r .ELEMENT)
  18. http { "state": "success", “sessionId”: "da990f64-671f-4b4e-b4f9-af3363fb54e8", "hCode": 1209818291, "value": {

    "ELEMENT": "0" }, "class": "org.openqa.selenium.remote.Response", "status": 0 }    success ID
  19. OSC19do   echo “{¥“value¥”:[¥“OSC19do  ¥n¥"]}” | ¥ http

    POST localhost:9515 /session/${SESSION_ID} /element/${ELEMENT_ID}/value) #() URI 
  20.    TITLE="" while [ "${TITLE}" != " OSC19do

     - Google " ] do RESPONSE=$(http GET ¥ localhost:9515/session/${SESSION_ID}/title) TITLE=$(echo ${RESPONSE} | jq -r .value) done
  21.   RESPONSE=$(echo ¥ ”{¥“using¥”:¥”link text¥”,¥ ¥“value¥”:¥“6/1 OSC19do  –

    connpass¥”}” | ¥ http POST localhost:9515 /session/${SESSION_ID}/element) # ( ) URI # ELEMENT_ID ID ELEMENT_ID=$(echo ${RESPONSE} | jq -r .status)
  22.  http POST ¥ localhost:9515 /session/${SESSION_ID} /element/${ELEMENT_ID}/click # () URI

  23. iFrame STATE ="" while ["${STATE}" != 0 ] do RESPONSE=$(echo

    "{¥"id¥":{¥"ELEMENT¥":¥"${ELEMENT_ID}¥"}}" | ¥ http POST ¥ localhost:9515/session/${SESSION_ID}/frame) TITLE=$(echo ${RESPONSE} | jq -r . status) done     iFrame   
  24. ( ) http DELETE localhost:9515/session/${SESSION_ID} pkill chromedriver

  25.     

  26.  bash" '%# Google Chrome   • Chrome Driver

    • http!&($HTTP' "# Chrome Driver   • JSON   https://github.com/hirokundayon/Emily
  27.  

  28. None
  29.  (^.^)/~~~