| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import time
- import random
- def type(e, text, delay=0.1):
- for c in text:
- e.type(c)
- sleep(0, delay)
- def filter_by_value(elements, value):
- return [e for e in elements if e.value.strip() == value]
- def sleep(min_delay, random_delay):
- time.sleep(min_delay + random_delay * random.random())
- def get_tag_ids(html, tag):
- start_idx = 0
- res = []
- while html.find(tag, start_idx) >= 0:
- idx = html.find(tag, start_idx)
-
- s = idx
- while html[s] != '<':
- s -= 1
- e = idx
- while html[e] != '>':
- e += 1
- id_start_idx = html.find('id="', s) + 4
- id_end_idx = html.find('"', id_start_idx)
-
- if id_start_idx < s or id_start_idx > e or id_end_idx < s or id_end_idx > e:
- print 'could not find id in %s' % html[s:e]
- start_idx = idx + 1
- continue
-
- res.append(html[id_start_idx:id_end_idx])
- start_idx = idx + 1
- return res
|