由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 同主题转寄 (转载)
相关主题
MySQL 存储 中文出现乱码,用的 hibernate请问哪里有python的code example
python regexp questionpython+ beautifulsoup 爬网页怎么那么复杂?
问个用python scratch yelp html 数据的问题Python做计算怎么只用一个核?
cookie的问题那位大侠介绍一下python的webcrawler吧
请各位大牛指点,感激不尽 : Python Script 关于登录 mitbbs 的问题有啥好轮子可以抓取网页里的不规则信息?
gmail用啥语言写的?https://mail.google.com/mail/u/0/?shva=1#inbox解析一下。菜鸟求助:怎么自动include header file?
这里人多,请问Java如何读取需要登录的网页的内容 (转载)url header问题
请教html中的hrefask a question about compile shared library using libtool
相关话题的讨论汇总
话题: renext话题: gbk话题: import话题: subject话题: printtext
进入Programming版参与讨论
1 (共1页)
s*******n
发帖数: 38
1
【 以下文字转载自 sysop 讨论区 】
发信人: samaritan (Good+Samaritan), 信区: sysop
标 题: 同主题转寄
发信站: BBS 未名空间站 (Thu Aug 18 19:32:26 2011, 美东)
这个bbs有不有同主题转寄的功能啊?有不有script作同主题转寄?
t****t
发帖数: 6806
2
好奇问一下, 这个"有不有"是哪里的方言?
N***m
发帖数: 4460
3
老大你真厉害,

【在 t****t 的大作中提到】
: 好奇问一下, 这个"有不有"是哪里的方言?
s*******n
发帖数: 38
4
【 以下文字转载自 sysop 讨论区 】
发信人: samaritan (Good+Samaritan), 信区: sysop
标 题: 同主题转寄
发信站: BBS 未名空间站 (Thu Aug 18 19:32:26 2011, 美东)
这个bbs有不有同主题转寄的功能啊?有不有script作同主题转寄?
t****t
发帖数: 6806
5
好奇问一下, 这个"有不有"是哪里的方言?
N***m
发帖数: 4460
6
老大你真厉害,

【在 t****t 的大作中提到】
: 好奇问一下, 这个"有不有"是哪里的方言?
s*******n
发帖数: 38
7
写了个同主题转寄的python script. 就是附件还不work. mitbbs的附件bs直接pass.
python新手。边学边编的。
----------------------------------------------
from urllib import request
from bs4 import BeautifulSoup, NavigableString
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
from email.header import Header
#password=sys.argv[1]
password='*****'
address='http://www.mitbbs.com/article_t/Programming/17234582.html'
urlBase='http://www.mitbbs.com'
page = urllib.request.urlopen(address).read()
reNext = r'下页'
nextURL=re.findall(re.compile(reNext), page.decode('gbk', 'replace'))
reNext = r'(.*?)'
subject=re.findall(re.compile(reNext), page.decode('gbk','replace'))
subject="".join(subject);
page=page.decode('gbk','replace');
old_stdout=sys.stdout
myio=io.StringIO()
sys.stdout=myio
soup = BeautifulSoup(page, from_encoding='gbk')
def printText(tags):
for tag in tags:
if tag.__class__ == NavigableString:
print(tag),
else:
printText(tag)
printText(soup.findAll("p"))
while len(nextURL):
curURL = (urlBase+nextURL[0])
page = urllib.request.urlopen(curURL).read()
reNext = r'下页'
nextURL=re.findall(re.compile(reNext), page.decode('gbk'))
soup = BeautifulSoup(page, from_encoding='gbk')
print("")
print(r'==================NEXT PAGE=======================')
print("")
printText(soup.findAll("p"))
sys.stdout=old_stdout
message=myio.getvalue()
fromaddr='f******[email protected]'
toaddr='t****[email protected]'
username = 'u******[email protected]'
def mail(to, subject, text):
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
subjectHdr = Header(subject.encode('gbk'),'gb2312')
msg['Subject'] = subjectHdr
msg.attach(MIMEText(text.encode(), _charset='utf-8'))
#part = MIMEBase('application', 'octet-stream')
#part.set_payload(open(attach, 'rb').read())
#encoders.encode_base64(part)
#part.add_header('Content-Disposition','attachment; filename="%s"' % os.
path.basename(attach))
#msg.attach(part)
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(username, password)
mailServer.sendmail(username, to, msg.as_string())
# Should be mailServer.quit(), but that crashes...
mailServer.close()
mail(toaddr, subject, message)
1 (共1页)
进入Programming版参与讨论
相关主题
ask a question about compile shared library using libtool请各位大牛指点,感激不尽 : Python Script 关于登录 mitbbs 的问题
which header file declares ntohs() in c++ ?gmail用啥语言写的?https://mail.google.com/mail/u/0/?shva=1#inbox解析一下。
HTTP Error 403这里人多,请问Java如何读取需要登录的网页的内容 (转载)
Help -- How to output error messages to a file for scripts called by system calls???请教html中的href
MySQL 存储 中文出现乱码,用的 hibernate请问哪里有python的code example
python regexp questionpython+ beautifulsoup 爬网页怎么那么复杂?
问个用python scratch yelp html 数据的问题Python做计算怎么只用一个核?
cookie的问题那位大侠介绍一下python的webcrawler吧
相关话题的讨论汇总
话题: renext话题: gbk话题: import话题: subject话题: printtext