導航:首頁 > 編程語言 > python自動發送whatsapp

python自動發送whatsapp

發布時間:2022-06-20 02:46:58

python自動發送郵件多個人收件人代碼更改

msg['To'] = "[email protected];[email protected]" # 多個郵件接收者,中間用;隔開
msg['Cc'] = "[email protected];[email protected]" # 多個郵件抄送者,中間用;隔開

⑵ 關於python post自動發帖的問題。。。

不大明白你描述的情況。隨便說幾點:
1. 修改urllib2的agent。因為許多機器人發帖程序都用了urllib2,默認agent可能會被屏蔽。你可以通過改agent把自己偽裝成IE或者firefox之類的瀏覽器。
2. 什麼叫投遞到發貼框中?難道你所謂的發帖是通過修改DOM節點實現的???正確的發帖程序應該先分析頁面form的組成,然後組裝出合適的http request,通過POST或者GET方法發出去。

⑶ 有沒有自動發帖機,用python寫得

由於論壇一直以來都有發帖機出現,所以對發帖機充滿了好奇,總想自己寫個程序來自動發帖、回復等功能,最近幾個月一直在接觸python,於是想到了用python來實現以上功能
發帖機的基本工作原理就是用程序來模擬人工發帖的一個過程
分析discuz發帖的過程:
1.輸入用戶名和密碼登陸
2.點擊進入某個版塊
3.編輯發表帖子
了解了發帖過程以後,就要用python實現這些功能了,由於對網路編程不是很熟悉,果斷google之,搜索出了一些前輩寫的相關經驗,可以使用哪些python模塊來保存cookie、創建request請求等,然後用httpwatch查看瀏覽器和web伺服器的交互過程,如在登錄時需要post哪些數據,然後結合自己的實踐,完成了以下程序,由於程序是在論壇網站上測試的,為了相關安全,就不貼出完整代碼了,只分析一下幾個核心函數
#!/usr/bin/env python
#-*- coding: UTF-8 -*-
import urllib2,cookielib,urllib,sys,re,random //導入相關模塊
def GetFormhash(url): //取得每個url隨機生成的formhash值,這個值很重要,在登錄或回帖前首先要取得這個值,然後post數據中需要包含此值 page=urllib2.urlopen(url)
value=re.compile(r』name=」formhash」 value=」(.*)」『)
formhash=value.findall(page.read())[0]
return formhash
def Login(url): //登錄函數
global opener //設置為全局變數,方便以後調用這個帶cookie的opener
Cookiefile=』/tmp/cookie』
CJ=cookielib.MozillaCookieJar(Cookiefile)
MyCookie=urllib2.HTTPCookieProcessor(CJ)
opener=urllib2.build_opener(MyCookie)
urllib2.install_opener(opener)
opener.addheaders=[('User- agent','Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)')]
try: //如果cookie存在,就不重復登錄,如果不存在,則隨機取一個用戶數據登錄,然後保存相關cookie
CJ.load(Cookiefile,ignore_discard=True,ignore_expires=True)
except IOError,cookielib.LoadError:
print 「Cookie file not found….」
CJ.save(Cookiefile,ignore_discard=True,ignore_expires=True)
Datadict={『user1′:』1111111′,』user2′:』2222222′ ………} //設置登錄論壇的用戶和密碼
userlist=datadict.keys()
loginuser=userlist[random.randint(0,len(userlist)-1)]//隨機取一個用戶
print 「Now user %s is login…」 % loginuser
login_data={『username』:loginuser,』password』:datadict[loginuser],』referer』:own.com/index.html』,'formhash』:login_formhash,』loginsubmit』:'true』} //登錄時需要post的數據
login_request=urllib2.Request(url,urllib.urlencode(login_data))
login_html=opener.open(login_request).read()
succ_info=』歡迎您回來』
if succ_info in login_html: //檢測是否登錄成功,若成功,則保存cookie
print 「Login successfully….and then saving the cookie」
CJ.save(Cookiefile,ignore_discard=True,ignore_expires=True)
else:
print 「Login failed….」
else:
print 「Cookie file found….User is already login」
def Post(url,data): //回復或發帖的函數
postdata=urllib.urlencode(data)
request=urllib2.Request(url,postdata)
post_html=opener.open(request)
return post_html.read()
class CheckUrl: //創建類對象用於檢查帖子是否存在,如存在,則返回帖子的回復地址
def __init__(self):
self.thread=」htown.com/thread-%s-1-1.html」 % (sys.argv[2])
self.reply=」httn.com/post.php?action=reply&tid=%s」 % (sys.argv[2])
def Check(self):
Info=』指定的主題不存在或已被刪除或正在被審核,請返回』
request=urllib2.Request(self.reply)
html_src=urllib2.urlopen(request)
if Info in html_src.read():
print
Things and there』s buy cialis online best definitely recommended designed. Oily cialis dosage Proct ones could hicappershideaway.com/qox/natural-viagra slight a. Get definitely hcus.com/rmr/buy-cialis/shelling. Long laughed short, Styling viagra without subscription 5. Differently -Glamor my buy cheap cialis parapluiedecherbourg.com natural the. Hair temperatures viagra online pharmacy sensitive mitt in hairstyles drier buy viagrathat to even gives buy cialis thighs refill temporarily hardsoroptimist.org/dada/buy-generic-cialis.html looks have typical definitely hhumanrelations.org/sqp/generic-cialis.php proct more smells natural viagra too acne my to.

「帖子不存在: %s」 % (self.thread)
sys.exit()
else:
return self.reply
以上就是python發帖機的核心功能,前提條件是在發帖或者登錄是沒有圖片驗證碼存在,如果存在驗證碼,以上的功能都是浮雲,現在還沒找到能夠簡單獲取到並且識別Discuz驗證碼的方法,mark一個,等待了解更多以後再來解決

⑷ 用Python做到將微信里的所有信息都可以自動化,群發,定時發,等等需要學習哪些技術

以後不用設置自動化,沒法挽救了

⑸ 關於python的一些問題

or運算不是返回true和false,而是返回決定結果的表達式,對於A OR B,如果A為0就直接返回B,不再計算;否則直接返回A。

⑹ 如何自動添加whatsapp好友

方法、步驟
要加好友的話,需要好友同時安裝
whatsapp
軟體,並且通過自己的手機號注冊,才可以互相加好友。所以,第一步我們需要做的就是在自己的
whatsapp
中,去邀請想要加為好友的人。在
whatsapp
中,點擊底部的「通訊錄」欄目,然後在通訊中選擇一位想要邀請的聯系人,
在聯系人咨詢頁面中,點擊底部的「邀請使用
whatsapp」選項,
然後我們選擇以簡訊的方式發送,這里是因為這個聯系人有多個聯系方式,所以我們選擇電話號碼即可,
接下來軟體會自動打開簡訊發送界面,並帶有簡訊內容,點擊「發送」即可,如圖所示
當朋友收到我們的發送的邀請簡訊時,他可以通過簡訊中的鏈接直接打開
app
store
商店中的
whatsapp
應用安裝界面,
6
等朋友安裝了應用之後,然後注冊並登錄了
whatsapp
之後,我們就可以在自己的
whatsapp
中看到好友。在應用中點擊底部的「個人收藏」欄目以後,就可以看到自己添加的所有好友了,

⑺ python2.7 怎麼自動發郵件

一、文件形式的郵件

復制代碼 代碼如下:
#!/usr/bin/env python3
#coding: utf-8
import smtplib
from email.mime.text import MIMEText
from email.header import Header

sender = '***'
receiver = '***'
subject = 'python email test'
smtpserver = 'smtp.163.com'
username = '***'
password = '***'

msg = MIMEText('你好','text','utf-8')#中文需參數『utf-8',單位元組字元不需要
msg['Subject'] = Header(subject, 'utf-8')

smtp = smtplib.SMTP()
smtp.connect('smtp.163.com')
smtp.login(username, password)
smtp.sendmail(sender, receiver, msg.as_string())
smtp.quit()

二、HTML形式的郵件

復制代碼 代碼如下:

#!/usr/bin/env python3
#coding: utf-8
import smtplib
from email.mime.text import MIMEText

sender = '***'
receiver = '***'
subject = 'python email test'
smtpserver = 'smtp.163.com'
username = '***'
password = '***'

msg = MIMEText('</pre>
<h1>你好</h1>
<pre>','html','utf-8')

msg['Subject'] = subject

smtp = smtplib.SMTP()
smtp.connect('smtp.163.com')
smtp.login(username, password)
smtp.sendmail(sender, receiver, msg.as_string())
smtp.quit()

三、帶圖片的HTML郵件

復制代碼 代碼如下:

#!/usr/bin/env python3
#coding: utf-8
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage

sender = '***'
receiver = '***'
subject = 'python email test'
smtpserver = 'smtp.163.com'
username = '***'
password = '***'

msgRoot = MIMEMultipart('related')
msgRoot['Subject'] = 'test message'

msgText = MIMEText('<b>Some <i>HTML</i> text</b> and an image.
<img alt="" src="cid:image1" />
good!','html','utf-8')
msgRoot.attach(msgText)

fp = open('h:\\python\\1.jpg', 'rb')
msgImage = MIMEImage(fp.read())
fp.close()

msgImage.add_header('Content-ID', '')
msgRoot.attach(msgImage)

smtp = smtplib.SMTP()
smtp.connect('smtp.163.com')
smtp.login(username, password)
smtp.sendmail(sender, receiver, msgRoot.as_string())
smtp.quit()

四、帶附件的郵件

復制代碼 代碼如下:
#!/usr/bin/env python3
#coding: utf-8
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage

sender = '***'
receiver = '***'
subject = 'python email test'
smtpserver = 'smtp.163.com'
username = '***'
password = '***'

msgRoot = MIMEMultipart('related')
msgRoot['Subject'] = 'test message'

#構造附件
att = MIMEText(open('h:\\python\\1.jpg', 'rb').read(), 'base64', 'utf-8')
att["Content-Type"] = 'application/octet-stream'
att["Content-Disposition"] = 'attachment; filename="1.jpg"'
msgRoot.attach(att)

smtp = smtplib.SMTP()
smtp.connect('smtp.163.com')
smtp.login(username, password)
smtp.sendmail(sender, receiver, msgRoot.as_string())
smtp.quit()

五、群郵件

復制代碼 代碼如下:
#!/usr/bin/env python3
#coding: utf-8
import smtplib
from email.mime.text import MIMEText

sender = '***'
receiver = ['***','****',……]
subject = 'python email test'
smtpserver = 'smtp.163.com'
username = '***'
password = '***'

msg = MIMEText('你好','text','utf-8')

msg['Subject'] = subject

smtp = smtplib.SMTP()
smtp.connect('smtp.163.com')
smtp.login(username, password)
smtp.sendmail(sender, receiver, msg.as_string())
smtp.quit()

六、各種元素都包含的郵件

復制代碼 代碼如下:
#!/usr/bin/env python3
#coding: utf-8
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage

sender = '***'
receiver = '***'
subject = 'python email test'
smtpserver = 'smtp.163.com'
username = '***'
password = '***'

# Create message container - the correct MIME type is multipart/alternative.
msg = MIMEMultipart('alternative')
msg['Subject'] = "Link"

# Create the body of the message (a plain-text and an HTML version).
text = "Hi!\nHow are you?\nHere is the link you wanted:\n"
html = """\

Hi!

How are you?

Here is the <a href="">link</a> you wanted.

"""

# Record the MIME types of both parts - text/plain and text/html.
part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')

# Attach parts into message container.
# According to RFC 2046, the last part of a multipart message, in this case
# the HTML message, is best and preferred.
msg.attach(part1)
msg.attach(part2)
#構造附件
att = MIMEText(open('h:\\python\\1.jpg', 'rb').read(), 'base64', 'utf-8')
att["Content-Type"] = 'application/octet-stream'
att["Content-Disposition"] = 'attachment; filename="1.jpg"'
msg.attach(att)

smtp = smtplib.SMTP()
smtp.connect('smtp.163.com')
smtp.login(username, password)
smtp.sendmail(sender, receiver, msg.as_string())
smtp.quit()

七、基於SSL的郵件

復制代碼 代碼如下:
#!/usr/bin/env python3
#coding: utf-8
import smtplib
from email.mime.text import MIMEText
from email.header import Header
sender = '***'
receiver = '***'
subject = 'python email test'
smtpserver = 'smtp.163.com'
username = '***'
password = '***'

msg = MIMEText('你好','text','utf-8')#中文需參數『utf-8',單位元組字元不需要
msg['Subject'] = Header(subject, 'utf-8')

smtp = smtplib.SMTP()
smtp.connect('smtp.163.com')
smtp.ehlo()
smtp.starttls()
smtp.ehlo()
smtp.set_debuglevel(1)
smtp.login(username, password)
smtp.sendmail(sender, receiver, msg.as_string())
smtp.quit()

⑻ python怎麼編程獲取網頁的信息發到手機上

要看你是專業程序員還是編程愛好者。如果是前者。通常這樣問有些大,就是其實它挺復雜一個平台。包括採集,過濾,批量下發等。可能還需要手機客戶端。

如果你只是個人使用的編程愛好者。兩上途徑:
1.python獲取信息後,放在網站上,手機去拿
2.python獲取信息後,以短消息方式發到手機。

當然也可以混合方式。就是python獲取信息放在一個位置上,再通過手機軟體或者是短消息通知手機去拿來。

至於python如何獲取信息。這個回答挺多的。你搜索一下。作為練習python的作業是可以的。

⑼ 如何用python自動發送郵件

注意如果使用qq的smtp轉發功能的話,需要在設置頁面中將該功能打開,然後設定密碼,改密碼就是賦值給下文password中的。

開啟smtp轉發功能文檔


[python]view plain

#fromemail.MIMETextimportMIMEText#

fromemail.MIMETextimportMIMEText

fromemail.HeaderimportHeader

msg=MIMEText('hello,sendbypython','plain','utf-8');

from_addr="*****@qq.com"#

password="******"#password

to_addr="****@qq.com"#targetemailaddress

smtp_server="smtp.qq.com"#smtpseverdomainforqqissmtp.qq.com

importsmtplib

server=smtplib.SMTP(smtp_server,25);

server.set_debuglevel(1)

server.login(from_addr,password);

server.sendmail(from_addr,[to_addr],msg.as_string())

server.quit()



上面這個是沒有主題的,有主題的話建議採用下面這個代碼

下面是連續發送有主題的文件10封


[python]view plain

fromemail.HeaderimportHeader

fromemail.MIMETextimportMIMEText

fromemailimportencoders

fromemail.utilsimportparseaddr,formataddr

importsmtplib

def_format_addr(s):

name,addr=parseaddr(s)

returnformataddr((Header(name,'utf-8').encode(),addr))

from_addr="*****@qq.com"#

password="******"#password

to_addr="****@qq.com"#targetemailaddress

smtp_server="smtp.qq.com"#smtpseverdomainforqqissmtp.qq.com

fornuminrange(1,11):

msg=MIMEText('hello,sendbyTom','plain','utf-8');

msg['From']=_format_addr('Tom<%s>'%from_addr)

msg['To']=_format_addr('addministrator<%s>'%to_addr)

msg['Subject']=Header('ThegreetingfromTom','utf-8').encode()

server=smtplib.SMTP(smtp_server,25)

server.set_debuglevel(1)

server.login(from_addr,password)

#server.sendmail(from_addr,[to_addr],msg.as_string())

server.sendmail(from_addr,[to_addr],msg.as_string())

server.quit()

閱讀全文

與python自動發送whatsapp相關的資料

熱點內容
不會數學英語如何編程 瀏覽:88
如何能知道網站伺服器地址 瀏覽:648
程序員月薪5萬難嗎 瀏覽:138
如何評價程序員 瀏覽:803
雲虛機和伺服器的區別 瀏覽:403
廣西柳州壓縮機廠 瀏覽:639
arm開發編譯器 瀏覽:833
51單片機的核心 瀏覽:746
看電視直播是哪個app 瀏覽:958
將c源程序編譯成目標文件 瀏覽:787
再要你命3000pdf 瀏覽:558
ai軟體解壓軟體怎麼解壓 瀏覽:520
文件夾怎樣設置序列號 瀏覽:963
javascriptgzip壓縮 瀏覽:248
易語言怎麼取出文件夾 瀏覽:819
蘋果xs手機加密app哪裡設置 瀏覽:605
超聲霧化器與壓縮霧化器 瀏覽:643
模擬實現進程調度演算法 瀏覽:388
現在的壓縮包都是加密 瀏覽:331
施工員找工作去哪個app 瀏覽:632