Commit 03e1e79b by Ed Crewe

user add dom

parent 5f46e707
...@@ -53,8 +53,20 @@ def get_ticket(page, app_url): ...@@ -53,8 +53,20 @@ def get_ticket(page, app_url):
starts = [app_url,'?ticket='] starts = [app_url,'?ticket=']
return find_in_page(page, starts, '"') return find_in_page(page, starts, '"')
def find_in_dom(page, top, parent, child):
""" Use dom to get values from page """
from xml.dom import minidom
dom = minidom.parseString(page)
topdom = dom.getElementsByTagname(top)[0]
return dom.getElementsByTagname(parent)[0].
getElementsByTagname(child)[0].
getAttribute('data')
def find_in_page(page, starts, stop): def find_in_page(page, starts, stop):
""" make this less ugly and more generic with regex """ """ Replace this with find_in_dom ?
Although without knowing the CAS login page this
is probably more generic.
"""
end = page.find(starts[0]) end = page.find(starts[0])
start = end + page[end:].find(starts[1]) + len(starts[1]) start = end + page[end:].find(starts[1]) + len(starts[1])
end = start + page[start:].find(stop) end = start + page[start:].find(stop)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment