mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-08-08 14:32:23 -04:00
First few behaviors
This commit is contained in:
parent
fe1c68af90
commit
445288d5e7
3 changed files with 59 additions and 6 deletions
13
umbra/behaviors.py
Normal file
13
umbra/behaviors.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
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))))
|
Loading…
Add table
Add a link
Reference in a new issue