def deletethread(threadid, username, receiverid): didntmsgbacklist = OkCupid.getlist('./Lists/DidntMsgBack.txt') didntmsgbacklist.append(username) OkCupid.writelisttofile('./Lists/DidntMsgBack.txt', didntmsgbacklist) body = { 'deletethread' : 'DELETE', 'mailaction' : '3', 'buddyname' : username, 'r1' : username, 'threadid' : threadid, 'receiverid' : receiverid, 'folderid' : '2', 'body_to_forward' : ''} data = urllib.urlencode(body) delurl = 'http://www.okcupid.com/mailbox?readmsg=true&threadid=' + threadid + '&folder=2' delrequest = urllib2.Request(delurl, data, OkCupid.cookiedict) delrespon = urllib2.urlopen(delrequest)
def deletethread(threadid, username, receiverid): didntmsgbacklist = OkCupid.getlist('./Lists/DidntMsgBack.txt') didntmsgbacklist.append(username) OkCupid.writelisttofile('./Lists/DidntMsgBack.txt', didntmsgbacklist) body = { 'deletethread': 'DELETE', 'mailaction': '3', 'buddyname': username, 'r1': username, 'threadid': threadid, 'receiverid': receiverid, 'folderid': '2', 'body_to_forward': '' } data = urllib.urlencode(body) delurl = 'http://www.okcupid.com/mailbox?readmsg=true&threadid=' + threadid + '&folder=2' delrequest = urllib2.Request(delurl, data, OkCupid.cookiedict) delrespon = urllib2.urlopen(delrequest)
def loadlists(): global sendmsgsto sendmsgsto = OkCupid.getlist(listpath) global sentamessage sentamessage = OkCupid.getlist("./Lists/SentAMessage.txt")
request = urllib2.build_opener() request.addheaders.append(OkCupid.cookietuple) returnedpage = request.open(url) usernamehtml = BeautifulSoup(returnedpage.read()).findAll("span", { "class" : "username" }) finallist = [] for i in usernamehtml: finallist.append(i.text.encode("utf-8")) return finallist if __name__ =='__main__': maindir = os.getcwd() queries = json.load(open('queries.json')) for query in queries: filterout = [] for i in query['filterout'] filterout += OkCupid.getlist(i.encode("utf-8")) currentlist = OkCupid.getlist(query['filepath'].encode("utf-8")) while True: print(query['name'].encode("utf-8") + ' List Count: ' + str(len(currentlist))) matched = [] matchcount = 0 #url manipulation code #currenturl = query['queryurl'].encode("utf-8") #re.sub('timekey=[0-9]', '', url) #&low=501&count=50 potentials = getpageusernames(query['queryurl'].encode("utf-8")) for potential in potentials: if potential in filterout: continue else: matchcount += 1