1.meta传达参数
上代码:

1.company_name使用回调函数的meta方法传递给parse_pagetwo内
2.可以通过在parse_pagetwo下:
name = response.meta['name']
将company_name取出
3.当然也是可以传递多个参数,因为是dict类型嘛
2.使用python发送邮件!
直接上代码,copy就好了
#导入smtplib模块
from smtplib import SMTP
from email.mime.text import MIMEText
from email.header import Header
'''邮件服务地址,发送邮箱,密码,接受邮箱,主题,内容'''
def send_email(SMTP_host, from_addr, password, to_addrs, subject, content):
email_client = SMTP(SMTP_host)
email_client.login(from_addr, password)
msg = MIMEText(content,'plain','utf-8')
msg['Subject'] = Header(subject, 'utf-8')#subject
msg['From'] = '发送人@163.com'
msg['To'] = "接收人@qq.com"
#sendmail(邮件发送者地址,字符串列表(收件人),发送内容)
email_client.sendmail(from_addr, to_addrs, msg.as_string())
send_email("smtp.163.com","发送人@163.com","xx","xx@qq.com","hello how do you do ?","i miss you xuehui !")
记得修改自己的邮箱账号密码,也别忘了注册邮箱,数字邮箱,不是普通邮箱!
3.scrapy遇到不能导出csv文件
可以看到输出数据是正常的,因为人生苦短所以我使用了run.py代替我执行scrapy命令!

结果可想而知,是毛都没有一根,整理一晚上

解决:
那就是 动动勤劳的双手,手动输入

发现这个run怎么移都不好使

最后,发红包:

网友评论