mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-02-24 08:39:59 -05:00
14 lines
523 B
Python
14 lines
523 B
Python
![]() |
from json import dumps, load
|
||
|
from time import sleep
|
||
|
import os, re
|
||
|
|
||
|
behaviors_file = os.path.sep.join(__file__.split(os.path.sep)[:-1] + ['behaviors.json'])
|
||
|
def execute(url, ws, command_id):
|
||
|
sleep(5)
|
||
|
with open(behaviors_file) as js:
|
||
|
behaviors = load(js)
|
||
|
for behavior in behaviors:
|
||
|
if re.match(behavior['site'], url):
|
||
|
for script in behavior['scripts']:
|
||
|
ws.send(dumps(dict(method="Runtime.evaluate", params={"expression": script}, id=next(command_id))))
|