Untitled

mail@pastecode.io avatar
unknown
plain_text
21 days ago
502 B
4
Indexable
Never
def get_fen():
    "extract FEN out of from page"
    time.sleep(3)
    # html_source = chrome.page_source
    response = requests.get(chrome.current_url)
    html_source = response.content
    root = html.fromstring(html_source)
    scripts = root.xpath('//script/text()')
    for script in scripts:
        if 'lichess.startRound' in script:
            split = script.split('fen')
            fen = split[len(split) - 1].split('}')[0].split(':')[1]
            fen = fen[1:-1]
            return fen
Leave a Comment