4 from BeautifulSoup import BeautifulSoup
6 """Screen scrapes jira.mit.edu. Supposedly. Doesn't actually work yet.
8 You need to have a personal certificate named cert.pem in this
9 directory to run this script. You also need the abovementioned scripts.
10 The zephyr bindings can be gotten from ebroder's GitHub repository
11 located: http://github.com/ebroder/python-zephyr/tree/master
13 SSL server CA authentication is disabled because we don't know how to
14 make curl stop complaining.
16 Current difficulty is we are causing a NullPointer exception on
17 (we think) touchstone's servers."""
19 class Browser(object):
20 def __init__(self, **kwargs):
22 self.lastResult = None
23 def _callback(self, buf):
24 self.lastResult += buf
28 c.setopt(c.WRITEFUNCTION, self._callback)
29 for k,v in self.opts.items():
30 c.setopt(getattr(c, k), v)
33 return self.lastResult
34 def getPage(self, url):
35 return Page(url, self.get(url), self)
38 def __init__(self, url, contents, browser):
40 self.soup = BeautifulSoup(contents)
41 self.browser = browser
42 def submitForm(self, name, args ={}):
43 form = self.soup.find(name='form', attrs={"name": name})
44 if form == None: return False
45 dest = form.get('action', self.url)
46 # this has a lot of edge-cases that don't work
47 inputs = form.findAll(name='input')
50 vals[input[name]] = input[value]
51 for k,v in args.items():
53 return self.browser.getPage()
60 COOKIEJAR = "jirabot.cookie",
63 HTTPHEADER = ["Accept-Language: en-us,en;q=0.5"],
66 b.get("https://jira.mit.edu/jira/secure/Dashboard.jspa")
67 page = b.getPage("https://jira.mit.edu/jira/secure/mit_login.jsp?os_destination=/secure/Dashboard.jspa")
69 print page.submitForm('wayfForm1')
71 #c.setopt(c.URL, "https://jira.mit.edu/jira/sr/jira.issueviews:searchrequest-rss/temp/SearchRequest.xml?&pid=10185&updated%3Aprevious=-1w&sorter/field=updated&sorter/order=DESC&tempMax=1000")
73 #d = feedparser.parse(t.contents)