最新文章專題視頻專題關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
當前位置: 首頁 - 科技 - 知識百科 - 正文

python模擬登陸Tom郵箱示例分享

來源:懂視網(wǎng) 責編:小采 時間:2020-11-27 14:29:58
文檔

python模擬登陸Tom郵箱示例分享

python模擬登陸Tom郵箱示例分享: 代碼如下:def loginTom(username, password): url1 = ''' http://login.mail.tom.com/cgi/login ''' values = { 'type' : '0', 'user' : '%s' % username, 'in_username' : '%s@tom.com' % usern
推薦度:
導讀python模擬登陸Tom郵箱示例分享: 代碼如下:def loginTom(username, password): url1 = ''' http://login.mail.tom.com/cgi/login ''' values = { 'type' : '0', 'user' : '%s' % username, 'in_username' : '%s@tom.com' % usern

代碼如下:


def loginTom(username, password):
url1 = '''
http://login.mail.tom.com/cgi/login
'''

values = {
'type' : '0',
'user' : '%s' % username,
'in_username' : '%s@tom.com' % username,
'pass' : '%s' % password,
'style' : '21',
'verifycookie' : 'y'
}

data = urllib.urlencode(values)
req = urllib2.Request(url1, data)
response = opener.open(req)
data2 =response.read()

sid = re.search(r'(?<=(sid=)).*?(?=&)', data2).group()

url3 = '''
http://bjapp6.mail.tom.com/cgi/ldapapp?funcid=mails&sid=%s&fid=1
''' % sid
response = opener.open(url3)
data3 = response.read()

b = re.search(r'(?<=nTotalMailCount).*?(?=;)', data3).group()
c = re.search(r'\d.+', b).group()
num_per_page = 20
num_times = string.atoi(c) / 20
print( num_times )

index = 0
for match in re.finditer(r'(?<="Mbox_Td_Subject"\>).*?(?=\ index += 1
part1 = "第%d封郵件" % index
part2 = " %s" % match.group()
part1 = part1.decode('utf8').encode('gbk')
subject = re.search(r'(?<=\>).+', part2).group()
subject = part1.decode('gbk') + " " + subject.decode('gbk')
print( subject.encode('gbk'))

for i in xrange(num_times - 1):
url3 = '''
http://bjapp6.mail.tom.com/cgi/ldapapp?funcid=mails&sid=%s&fid=1&start=%d
''' % (sid, (i + 1) * num_per_page )
response = opener.open(url3)
data3 = response.read()

for match in re.finditer(r'(?<="Mbox_Td_Subject"\>).*?(?=\ index += 1
part1 = "第%d封郵件" % index
part2 = " %s" % match.group()
part1 = part1.decode('utf8').encode('gbk')
subject = re.search(r'(?<=\>).+', part2).group()
subject = part1.decode('gbk') + " " + subject.decode('gbk')
print( subject.encode('gbk'))

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:0731-84117792 E-MAIL:11247931@qq.com

文檔

python模擬登陸Tom郵箱示例分享

python模擬登陸Tom郵箱示例分享: 代碼如下:def loginTom(username, password): url1 = ''' http://login.mail.tom.com/cgi/login ''' values = { 'type' : '0', 'user' : '%s' % username, 'in_username' : '%s@tom.com' % usern
推薦度:
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top