找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 8975|回复: 27

简单三步实现安装飞信每天免费发天气预报、笑话……

[复制链接]
本帖最后由 何夜 于 2013-12-5 16:38 编辑

简单实现OP安装飞信免费发天气预报、笑话等一切皆有可能

看到ruoknow发了一则抛砖引玉贴https://www.right.com.cn/forum/thread-133288-1-1.html
一番折腾无极限后出个简单教程,分享这种免费的服务
考虑到大家的机子空间有限,把程序安装在U盘

1.下载附件,解压上传U盘或移动硬盘

2.登陆putty执行命令
安装python程序(安装在移动硬盘,安装在flash中的这步可以简化为 install python )
mkdir /mnt/sda1/packages/     
echo dest usb /mnt/sda1/packages/ >> /etc/opkg.conf
opkg update
opkg --dest usb install python
ln -s /mnt/sda1/packages/usr/bin/python /usr/bin/python
安装python模块
用WinSCP进入上传的三个文件中分别执行
python setup.py install
注意顺序
setuptools
feedparser
pywapfetion

3修改tp.py ,xh.py中的飞信手机号码和密码
OK 安装完毕
测试

执行python tq.py 手机收到三天内的天气预报
执行python xh.py 手机收到网站第一条笑话
修改天气预报的网站http://weather.raychou.com/?/list/
修改笑话的网站http://www.xiaohuayoumo.com/plus/rssmap.html

最后加入定时启动就OK了,路由器按照你设定的时间执行

大家运行可能遇到的问题就是字符编码问题
出现UnicodeEncodeError: 'ascii' codec can't encode charac………………错误
就用疼蛋的方法解决疼蛋的问题
在tq.py中增加三行代码(红色的)可以解决多数疼蛋字符编码问题,这样可以显示中文,有可以解决问题
#!/usr/bin/python
#-*-coding:utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import PyWapFetion
import feedparser
d = feedparser.parse('http://weather.raychou.com/?/detail/101260215/rss')
send_content = d.feed.title + "\n 今天" + d.entries[0].description + "\n 明天" + d.entries[1].description + "\n 后天" + d.entries[2].description
send_content = send_content.decode('utf-8').encode('gb2312')
print send_content
send_content = send_content.decode('gb2312').encode('utf-8')

PyWapFetion.send("157XXXX9168","XXXX123","157XXXX9168",send_content)



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

评分

参与人数 3恩山币 +7 收起 理由
失*** + 3 土豪,我们做朋友吧!
ja*** + 1 支持一下
jzm*** + 3 大大牛

查看全部评分

我的恩山、我的无线 The best wifi forum is right here.
简单三步系列么,支持一下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

现在花样越来越多了啊
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

来自手机 | 显示全部楼层
我是来看热闹的
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

来自手机 | 显示全部楼层
我来打酱油的,呵呵
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

小白求教~

root@OpenWrt:/home/packages/PyWapFetion# python tq.py
Traceback (most recent call last):
  File "tq.py", line 10, in <module>
    print send_content.decode('utf-8')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

支持下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

本帖最后由 jzmno1 于 2013-12-4 20:03 编辑

大大我菜菜,我没成功显示
tang> py tq.py
-ash: py: not found
tang> python tq.py
Traceback (most recent call last):
  File "tq.py", line 10, in <module>
    print send_content
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
tang> python tq.py
Traceback (most recent call last):
  File "tq.py", line 10, in <module>
    print send_content
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)应该安装成功了吧显示这样
tang> python setup.py install
running install
running bdist_egg
running egg_info
writing PyWapFetion.egg-info/PKG-INFO
writing top-level names to PyWapFetion.egg-info/top_level.txt
writing dependency_links to PyWapFetion.egg-info/dependency_links.txt
writing PyWapFetion.egg-info/PKG-INFO
writing top-level names to PyWapFetion.egg-info/top_level.txt
writing dependency_links to PyWapFetion.egg-info/dependency_links.txt
reading manifest file 'PyWapFetion.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'LICENSE'
writing manifest file 'PyWapFetion.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/PyWapFetion
copying build/lib/PyWapFetion/Errors.py -> build/bdist.linux-x86_64/egg/PyWapFetion
copying build/lib/PyWapFetion/AliveKeeper.py -> build/bdist.linux-x86_64/egg/PyWapFetion
copying build/lib/PyWapFetion/__init__.py -> build/bdist.linux-x86_64/egg/PyWapFetion
copying build/lib/PyWapFetion/Cache.py -> build/bdist.linux-x86_64/egg/PyWapFetion
copying build/lib/PyWapFetion/Fetion.py -> build/bdist.linux-x86_64/egg/PyWapFetion
byte-compiling build/bdist.linux-x86_64/egg/PyWapFetion/Errors.py to Errors.pyc
byte-compiling build/bdist.linux-x86_64/egg/PyWapFetion/AliveKeeper.py to AliveKeeper.pyc
byte-compiling build/bdist.linux-x86_64/egg/PyWapFetion/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/PyWapFetion/Cache.py to Cache.pyc
byte-compiling build/bdist.linux-x86_64/egg/PyWapFetion/Fetion.py to Fetion.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying PyWapFetion.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying PyWapFetion.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying PyWapFetion.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying PyWapFetion.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying PyWapFetion.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
creating 'dist/PyWapFetion-0.9.4-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing PyWapFetion-0.9.4-py2.7.egg
removing '/volume1/@appstore/Python/usr/local/lib/python2.7/site-packages/PyWapFetion-0.9.4-py2.7.egg' (and everything under it)
creating /volume1/@appstore/Python/usr/local/lib/python2.7/site-packages/PyWapFetion-0.9.4-py2.7.egg
Extracting PyWapFetion-0.9.4-py2.7.egg to /volume1/@appstore/Python/usr/local/lib/python2.7/site-packages
PyWapFetion 0.9.4 is already the active version in easy-install.pth

Installed /volume1/@appstore/Python/usr/local/lib/python2.7/site-packages/PyWapFetion-0.9.4-py2.7.egg
Processing dependencies for PyWapFetion==0.9.4
Finished processing dependencies for PyWapFetion==0.9.4

我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
jzmno1 发表于 2013-12-4 19:55
大大我菜菜,我没成功显示
tang> py tq.py
-ash: py: not found

先安装PY程序,接下来安装py模块是有顺序的, 先用WinSCP进入setuptools文件夹运行python setup.py install,再进入feedparser运行python setup.py install,最后才进入pywapfetion-master运行python setup.py insta安装飞信模块
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

学习了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

  1. python tq.py
  2. Traceback (most recent call last):
  3.   File "tq.py", line 10, in <module>
  4.     print send_content
  5. UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)
复制代码


请问这个报错怎么解决呢
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

今天按照大大的方法又试了试还是不行
显示
Traceback (most recent call last):
  File "tq.py", line 10, in <module>
    print send_content
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordin
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

xh那个 多次运行 每次收到的笑话都是同一个0 0、、
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
lf0026 发表于 2013-12-6 10:25
xh那个 多次运行 每次收到的笑话都是同一个0 0、、

由于网站是几天更新一次,执行相同的命令收到的内容当然是相同的。你可以在不同时候执行不同的xxx.py,每个xxx.py只需修改d.entries[0]中的数字(0代表第一条,1代表第二条……)或者rss网站的地址
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

楼主啊..
为毛线我给别人发天气发不了那?
我手机号,密码 别人的手机号...然后就是发送不了那
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-27 02:06

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表