Skip to content

Commit

Permalink
add msg type 49 content
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyang committed May 17, 2016
1 parent 1c28e44 commit efb24cb
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions wxbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import os
import sys
import traceback
import webbrowser
import pyqrcode
import requests
Expand Down Expand Up @@ -39,13 +40,17 @@ def show_image(file_path):
webbrowser.open(file_path)

class SafeSession(requests.Session):
def request(self, *args, **kwargs):
def request(self, method, url, params=None, data=None, headers=None, cookies=None, files=None, auth=None,
timeout=None, allow_redirects=True, proxies=None, hooks=None, stream=None, verify=None, cert=None,
json=None):
for i in range(3):
try:
return super(SafeSession, self).request(*args, **kwargs)
except:
pass
return super(SafeSession, self).request(*args, **kwargs)
return super(SafeSession, self).request(method, url, params, data, headers, cookies, files, auth,
timeout,
allow_redirects, proxies, hooks, stream, verify, cert, json)
except Exception as e:
print e.message,traceback.format_exc()
continue


class WXBot:
Expand Down Expand Up @@ -244,6 +249,7 @@ def get_contact_name(self, uid):




@staticmethod
def get_contact_prefer_name(name):
if name is None:
Expand Down Expand Up @@ -475,14 +481,17 @@ def extract_msg_content(self, msg_type_id, msg):
'title': msg['FileName'],
'desc': self.search_content('des', content, 'xml'),
'url': msg['Url'],
'from': self.search_content('appname', content, 'xml')}
'from': self.search_content('appname', content, 'xml'),
'content':msg.get('content')#有的公众号会发一次性3 4条链接一个大图,如果只url那只能获取第一条,content里面有所有的链接
}
if self.DEBUG:
print ' %s[Share] %s' % (msg_prefix, app_msg_type)
print ' --------------------------'
print ' | title: %s' % msg['FileName']
print ' | desc: %s' % self.search_content('des', content, 'xml')
print ' | link: %s' % msg['Url']
print ' | from: %s' % self.search_content('appname', content, 'xml')
print ' | content: %s' % msg.get('content')[:20]
print ' --------------------------'

elif mtype == 62:
Expand Down

0 comments on commit efb24cb

Please sign in to comment.