| 10 | | from auth_dummy import user |
| | 11 | #from auth_dummy import user |
| | 12 | |
| | 13 | zeurl="https://staging.launchpad.net/bugs/51835" |
| | 14 | base_url = "https://staging.launchpad.net/" |
| | 15 | |
| | 16 | cookies = cookielib.CookieJar() |
| | 17 | req = urllib2.Request("https://staging.launchpad.net/") |
| | 18 | resp = urllib2.urlopen(req) |
| | 19 | cookies.extract_cookies(resp, req) |
| | 20 | |
| | 21 | def login(username, password): |
| | 22 | data = {'form': 'login', |
| | 23 | 'loginpage_email': username, |
| | 24 | 'loginpage_password': password, |
| | 25 | 'loginpage_submit_login': 'Log In'} |
| | 26 | url = base_url + 'products/+login' |
| | 27 | fetch(url, data) |
| | 28 | |
| | 29 | def fetch(url, data): |
| | 30 | postdata = urllib.urlencode(data) |
| | 31 | req = urllib2.Request(url, postdata) |
| | 32 | c = cookies._cookies_for_request(req)[0] |
| | 33 | req.add_header('Cookie', '%s=%s' % (c.name, c.value)) |
| | 34 | #print c.value |
| | 35 | return urllib2.urlopen(req).read() |
| | 36 | |
| | 37 | #editurl="to_get" |
| | 38 | login("","") |
| | 39 | #request= mecha.Request(zeurl) |
| | 40 | data={ 'field.status' : 'Rejected', |
| | 41 | 'FORM_SUBMIT' : 'Save Changes'} |
| | 42 | f= fetch(zeurl, data) |
| | 43 | print f |
| | 44 | |
| | 45 | #forms = ClientForm.ParseResponse(f, backwards_compat=False) |
| | 46 | #for i in forms : |
| | 47 | # print i |
| 18 | | soup = BeautifulSoup(f).body.contents[5].div.div |
| 19 | | title = soup.h1.contents[0] |
| 20 | | tbody = soup.findAll('tbody')[0].findAll('td') |
| 21 | | product = tbody[0].a.contents[0] |
| 22 | | status = tbody[1].contents[0] |
| 23 | | importance = tbody[2].contents[0] |
| | 54 | #soup = BeautifulSoup(f).body.contents[5].div.div |
| | 55 | #title = soup.h1.contents[0] |
| | 56 | #tbody = soup.findAll('tbody')[0].findAll('td') |
| | 57 | #product = tbody[0].a.contents[0] |
| | 58 | #status = tbody[1].contents[0] |
| | 59 | #importance = tbody[2].contents[0] |
| 31 | | array_com = soup.findAll('div', recursive=0)[1].findAll('div','boardComment') |
| 32 | | print array_com |
| 33 | | j = 0 |
| 34 | | com_counter = 0 |
| 35 | | for i in array_com : |
| 36 | | details = i.contents[1].findAll('a') |
| 37 | | title = details[0].strong.contents[0] |
| 38 | | poster = details[1].contents[0] |
| 39 | | body = i.contents[3].findAll('p') |
| 40 | | com_counter += 1 |
| 41 | | content="" |
| 42 | | for z in body : |
| 43 | | phrase = z.contents[0].string |
| 44 | | new_phrase = phrase.strip().replace(" "," ") |
| 45 | | content = "%s\n%s" %(content,new_phrase) |
| 46 | | newcom = comment(com_counter,content,poster,title,"date not implemented") |
| 47 | | zebug.addComment(newcom) |
| 48 | | j += 1 |
| 49 | | print zebug.comNbr() |
| | 67 | #array_com = soup.findAll('div', recursive=0)[1].findAll('div','boardComment') |
| | 68 | #print array_com |
| | 69 | #j = 0 |
| | 70 | #com_counter = 0 |
| | 71 | #for i in array_com : |
| | 72 | # details = i.contents[1].findAll('a') |
| | 73 | # title = details[0].strong.contents[0] |
| | 74 | # poster = details[1].contents[0] |
| | 75 | # body = i.contents[3].findAll('p') |
| | 76 | # com_counter += 1 |
| | 77 | # content="" |
| | 78 | # for z in body : |
| | 79 | # phrase = z.contents[0].string |
| | 80 | # new_phrase = phrase.strip().replace(" "," ") |
| | 81 | # content = "%s\n%s" %(content,new_phrase) |
| | 82 | # newcom = comment(com_counter,content,poster,title,"date not implemented") |
| | 83 | # zebug.addComment(newcom) |
| | 84 | # j += 1 |
| | 85 | #print zebug.comNbr() |