Analyzing Sina Weibo features (Python)

2018-01-22

Install Sina Weibo SDK

When you are handling with Python3+, you will face the following problem:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
HanslendeMacBook-Pro:SinaPython Hanslen$ pip install sinaweibopy
Collecting sinaweibopy
Using cached sinaweibopy-1.1.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/95/rr3dwmb55fb6g_fy4d_449240000gn/T/pip-build-6jcdnd_p/sinaweibopy/setup.py", line 4, in <module>
import weibo
File "/private/var/folders/95/rr3dwmb55fb6g_fy4d_449240000gn/T/pip-build-6jcdnd_p/sinaweibopy/weibo.py", line 166
except urllib2.HTTPError, e:
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/95/rr3dwmb55fb6g_fy4d_449240000gn/T/pip-build-6jcdnd_p/sinaweibopy/

This issue arises because this SDK is not compatible with Python3. To fix this issue, you need to run the following instead

1
sudo python2 -m pip install sinaweibopy

Common Erros

  1. Encoding Error:
1
SyntaxError: Non-ASCII character '\xe5' in file kNN.py on line 24, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Solution: Adding the following line at the start of the python program

1
# -*- coding: UTF-8 -*-

‚Äč

Example

Here are some examples check my Github Link:

https://github.com/Hanslen/Python_Spider/tree/master/SinaWeibo


Comments: