愛情公寓免費會員拜訪小窩留言程式[Python] v1.0.1

要是老玩家應該都知道

以前愛寓拜訪小窩是手寫文字傳心意

不像現在非vip只能用制式訊息

現在不用vip也能拜訪留言了

不過文字長度還是限制

並不是發送時的長度限制

而是在網頁顯示時如果文字過長會被遮住

此程式只供測試用途

不要用來做非法用途

免費拜訪小窩留言程式:按我下載
備註1:如果執行時出現cannot get zipimporter instance那就是要把檔案放在沒中文路徑下才能執行
備註2:免責聲明!如果用此程式發生被鎖帳號本站並不負責,用之前請三思

以下是原始碼:

# -*- coding: utf-8 -*-
'''
Created on 2011/12/13

@author: KK
'''
import tkinter as tk
import tkinter.messagebox
import http.cookiejar
import urllib.request
import urllib.parse
import re
import threading
import random

#設定標頭檔和cookie
cookie_jar = http.cookiejar.CookieJar()
cjhdr  =  urllib.request.HTTPCookieProcessor(cookie_jar)
opener = urllib.request.build_opener(cjhdr)

#------------------------------
def logins():
    cookie_jar.clear()#丟棄所有session和cookies
    user = user_var.get()
    password = password_var.get()
    url="https://login.i-part.com.tw/login.php"
    values={
            "f":"/file/file_my.php?",
            "password":password,
            "r":"http://www.i-part.com.tw/index.php",
            "username":user
            }
    datas=urllib.parse.urlencode(values)#轉為url資料傳輸碼
    binary_data = datas.encode('utf-8')
    opener.open(url,binary_data)#登入
    #登入後進入首頁抓取姓名
    user_cookie = cookie_check()
    if user_cookie:
        msg_var.set('登入成功')
    else:
        msg_var.set('登入失敗')
#------------------------------
def cookie_check():
    cookies = dict([(cookie.name, cookie.value) for cookie in cookie_jar])
    if 'SID' in  cookies.keys():
        return cookies['SID']
    else:
        return False
def online_check(people_id):
    people_id
    seach_data = opener.open("http://www.i-part.com.tw/file/file_viewfile.php?u=" + people_id).read().decode('utf-8','replace')
    if re.search('offline.gif', seach_data):
        return True
    else:
        return False

#---------------------------------------------------
def visit():
    msg_posting.config(text=str('拜訪小窩中...'))
    id_vars = id_var.get()
    postmsgs = post.get("1.0",tk.END)
    postmsgss = post.get("1.0",tk.END)
    str_len = len(postmsgss)
    if str_len > 22 :
        print('ssss')
    else:
        postmsgs = postmsgs.encode('utf-8')
        url="http://www.i-part.com.tw/room/room_visitroom.php?"
        values={
                "visit_gift":gifts[giftmenu.get()],
                "buycnt":"",
                "choose_type":"1",
                "visit_msg_2":postmsgs,
                "visit_msg_1":"",
                "room_owner":id_vars,
                "visit_msg":postmsgs,
                "Submit":"送出"
                }
        datas=urllib.parse.urlencode(values)#轉為url資料傳輸碼
        binary_data = datas.encode('utf-8')
        response = opener.open(url,binary_data).read().decode('utf-8','replace')#登入
        if '謝謝您來參觀唷' in response:
            msg_posting.config(text=str('拜訪小窩成功'))
        else:
            msg_posting.config(text=str('拜訪小窩失敗'))
#--------------------------------------------------
def thread_logins():
    msg_var.set('登入中...')
    thread = threading.Thread(target=logins)
    thread.start()
def thread_visit():
    user_cookie = cookie_check()
    if user_cookie:
        if len(post.get("1.0",tk.END)) > 20:
            tkinter.messagebox.showinfo("訊息", "文字長度過長" )
        else:
            thread = threading.Thread(target=visit)
            thread.start()
    else:
        tkinter.messagebox.showinfo("訊息", "請先登入" )

#----------------------------------------
def read_depots(file):
    depots = []
    depots_f = open(file)
    for line in depots_f:
        depots.append(line.rstrip())
    return depots

#----------------------------------------

app = tk.Tk()
app.title("免費小窩拜訪留言")
app.geometry('496x250+200+100')
app.resizable(width = False, height = False)#不讓它任意拉框

global_font=("Arial",11)



user_var = tk.StringVar()
user_var.set("")
password_var = tk.StringVar()
password_var.set("")

msg_var = tk.StringVar()
msg_var.set("")





#伴手禮變數(預設英式烘培小餅乾)
giftmenu = tk.StringVar()
giftmenu.set("英式烘培小餅乾")




#下方訊息
msgposting_var = tk.StringVar()
msgposting_var.set("")


#用戶ID
id_var = tk.StringVar()
id_var.set("")

#----------------------------------------------
#帳號欄位
user_lab = tk.Label(app, font=global_font, text="帳號:").place( height=30,x=10,y=10)
user=tk.Entry( app, font=global_font, width=10, textvariable = user_var).place( height=20,x=50,y=15)


#密碼欄位
password_lab = tk.Label(app, font=global_font, text="密碼:").place( height=30,x=130,y=10)
password=tk.Entry( app, font=global_font, width=10, show='*', textvariable = password_var).place( height=20,x=170,y=15)


#登入按鈕
login = tk.Button(app, font=global_font, text = "登入", width = 10, command = thread_logins).place( height=30, width=60,x=270,y=10)

#顯示訊息
msg = tk.Label(app, font=global_font, textvariable = msg_var).place( height=30,x=340,y=10)


#輸入用戶ID
tk.Label( app, font=global_font, text="住戶編號:").place( height=30,x=10,y=50)
tk.Entry( app, font=global_font, width=12, textvariable = id_var).place( height=20,x=90,y=55)


#city_menu
gift_id = read_depots("gift_id.txt")
gift = read_depots("gift.txt")
gifts = dict(zip(gift,gift_id))
tk.OptionMenu(app, giftmenu, *gift).place( height=30,x=200,y=50)


#text訊息框
post = tk.Text(app, font=global_font,height=10,width=59)
post.place( height=100,x=10,y=100)


#下方顯示訊息
msg_posting = tk.Label(app, font=global_font)
msg_posting.place(height=30,x=10,y=210)


#送出按紐
submit = tk.Button(app, font=global_font, text = "送出", command = thread_visit).place( height=30,x=300,y=210)







#------------------------------------------
app.mainloop()

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *