Skip to content

Commit

Permalink
fix bugs caused by sina weibo page changes
Browse files Browse the repository at this point in the history
  • Loading branch information
qinxuye committed Sep 3, 2013
1 parent dc7b173 commit fa5bc65
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
11 changes: 7 additions & 4 deletions cola/worker/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 166,13 @@ def _login(self, opener):
not isinstance(self.ctx.job.login, list):
raise ConfigurationError('If login_hook set, config files must contains `login`')
kw = random.choice(self.ctx.job.login)
login_success = self.job.login_hook(opener, **kw)
if not login_success:
self.logger.info('login fail')
return login_success
login_result = self.job.login_hook(opener, **kw)
if isinstance(login_result, tuple) and len(login_result) == 2:
self.logger.error('login fail, reason: %s' % login_result[1])
return login_result[0]
elif not login_result:
self.logger.error('login fail')
return login_result
return True

def _log_error(self, obj, err):
Expand Down
6 changes: 4 additions & 2 deletions contrib/weibo/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 98,9 @@ def login(self):

regex = re.compile('\((.*)\)')
json_data = json.loads(regex.search(text).group(1))
return json_data['result'] == True

result = json_data['result'] == True
if result is False and 'reason' in json_data:
return result, json_data['reason']
return result
except WeiboLoginFailure:
return False
4 changes: 2 additions & 2 deletions contrib/weibo/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 344,7 @@ def set_instance(instance, dl):
return [], []

params = urldecode(url)
new_params = urldecode('?%s'%(current_page 1))
new_params = urldecode('?page=%s'%(current_page 1))
params.update(new_params)
params['__rnd'] = int(time.time()*1000)
next_page = '%s?%s' % (url.split('?')[0] , urllib.urlencode(params))
Expand Down Expand Up @@ -519,7 519,7 @@ def parse(self, url=None):
except ValueError, e:
return self._error(url, e)
domid = data['domid']
if domid == 'Pl_Official_LeftHisRelation__15':
if domid == 'Pl_Official_LeftHisRelation__16':
html = beautiful_soup(data['html'])
if 'relate' in decodes and decodes['relate'] == 'fans':
is_follow = False
Expand Down

0 comments on commit fa5bc65

Please sign in to comment.