Selbst wenn ich es nachgeschlagen habe, ist es nicht leicht herausgekommen, also habe ich mir eine Notiz gemacht. (Bitte sag mir, ob es einen besseren Weg gibt)
--Lesen Sie die URL-Liste aus einer externen Datei (list.tsv)
screen_shot.robot
*** Settings ***
Library    SeleniumLibrary
Variables   ./import.py
*** Keywords ***
Create Chrome Driver
	${options} =  Evaluate  sys.modules['selenium.webdriver'].ChromeOptions()  sys
	Call method  ${options}  add_argument    --headless
	Create webdriver    Chrome    chrome_options=${options}
*** Test Cases ***
Stichwort
	Create Chrome Driver
    ${w} =    Execute JavaScript    return document.body.scrollWidth
    ${h} =    Execute JavaScript    return document.body.scrollHeight
    Set Window Size  ${w}  ${h}
    Set ScreenShot Directory    path=screenshot
    ${length}=  Get Length  ${conditions}
    :FOR    ${idx}  IN RANGE    ${length}
    \   Go To    @{urls}[${idx}]
    \   Capture Page Screenshot     filename=@{conditions}[${idx}].png
import.py
import csv
with open('list.tsv') as f:
    reader = csv.reader(f, delimiter='\t')
    l = [row for row in reader]
    l_T = [list(x) for x in zip(*l)]
    conditions = l_T[0]
    urls = l_T[1]
list.tsv
Katze https://www.google.com/search?q=%E3%81%AD%E3%81%93&tbm=isch
Inu https://www.google.com/search?q=%E3%81%84%E3%81%AC&tbm=isch
Saru https://www.google.com/search?q=%E3%81%95%E3%82%8B&tbm=isch
Recommended Posts