Comments (2)
@pcloth 这是我们这里程序的bug
不过我不用python3只能粗略的先帮你改一下,更新程序版本的事情要交给@chyroc了
解决方案如下
修改一下D:\Anaconda3\lib\site-packages\itchat\client.py
的__upload_file
内容为:
def __upload_file(self, fileDir, isPicture=False):
if not tools.check_file(fileDir): return
url = 'https://file%s.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' % (
'2' if '2' in self.loginInfo['url'] else '')
# save it on server
fileSize = str(os.path.getsize(fileDir))
cookiesList = {name: data for name, data in self.s.cookies.items()}
fileType = mimetypes.guess_type(fileDir)[0] or 'application/octet-stream'
files = {
'id': (None, 'WU_FILE_0'),
'name': (None, os.path.basename(fileDir)),
'type': (None, fileType),
'lastModifiedDate': (None, time.strftime('%a %b %d %Y %H:%M:%S GMT+0800 (CST)')),
'size': (None, fileSize),
'mediatype': (None, 'pic' if isPicture else 'doc'),
'uploadmediarequest': (None, json.dumps({
'BaseRequest': {k: v.decode('ascii') for k, v in self.loginInfo['BaseRequest'].items()},
'ClientMediaId': int(time.time()),
'TotalLen': fileSize,
'StartPos': 0,
'DataLen': fileSize,
'MediaType': 4,
}, separators=(',', ':'))),
'webwx_data_ticket': (None, cookiesList['webwx_data_ticket']),
'pass_ticket': (None, 'undefined'),
'filename': (os.path.basename(fileDir), open(fileDir, 'rb'), fileType),
}
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36'
}
r = self.s.post(url, files=files, headers=headers)
return json.loads(r.text)['MediaId']
通过测试的程序
#!python3
import itchat
itchat.auto_login()
itchat.send('@[email protected]')
from itchat.
完成更新:Fix upload file bug
from itchat.
Related Issues (20)
- Hi how i yours the App
- 现在微信网页版无法登录,还能用itchat吗 HOT 11
- iPhone手机上的8.0.43版本微信是不是改VOIP了?
- 视频号 HOT 1
- ???
- 错误
- 17年6月下旬前登陆过web网页版的微信可以使用此框架,验证微信是否支持web版本API,请点击https://wx.qq.com/ ,扫码验证即可,假如出现无法登陆,则不适用于此框架 HOT 3
- itchat.send_video 运行没有效果 HOT 2
- 如何获得微信群群人数
- 【无法登录】“为了保障你的账号安全,暂不支持使用网页版微信。你可以前往微信官网” HOT 3
- itchat.send('Hello, filehelper', toUserName='filehelper') Out[5]: <ItchatReturnValue: {'BaseResponse': {'Ret': 1, 'ErrMsg': '', 'RawMsg': ''}, 'MsgID': '', 'LocalID': ''}> HOT 2
- 【微信号】itchat可以获取微信好友列表所有人的微信号么
- 第一步扫码就出现问题 HOT 2
- 请问怎么发送群聊消息的时候@群成员,@全体,微信会有@的提醒通知 HOT 1
- 获取什么作为群聊用户的永久唯一标识? HOT 4
- set_alias修改好友备注接口怎么没有生效 HOT 3
- 我在登录后出现'xml.parsers.expat.ExpatError: mismatched tag: line 64, column 4' 怎么解决 HOT 9
- 国务院的人都是一群鲨跸 HOT 4
- 【!!!研发必看!!!】替代UOS WEB版,做机器人,小助手,营销系统,客服系统,监管系统的可以 看下这个API方案 HOT 5
- 能根据手机号获取微信头像昵称吗?个人签名。 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from itchat.