我试图使用Linkedin API来抓取有关公司的信息,但我有一个套接字错误:
Traceback (most recent call last):
File "/Users/anhvangiang/Desktop/PY/test.py", line 10, in <module>
application = server.quick_api(key, secret)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/linkedin/server.py", line 25, in quick_api
_wait_for_user_to_enter_browser(app)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/linkedin/server.py", line 39, in _wait_for_user_to_enter_browser
httpd = BaseHTTPServer.HTTPServer(server_address, MyHandler)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 417, in __init__
self.server_bind()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 431, in server_bind
self.socket.bind(self.server_address)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 48] Address already in use
我的代码是:
from linkedin import server
from socket import *
sock = socket()
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
key = "key"
secret = "secret"
application = server.quick_api(key, secret)
任何建议如何解决问题?
答案 0 :(得分:0)
您可以使用以下命令找到并终止该进程:
ps aux | grep python
使用以下命令获取进程ID并终止:
kill -9 PID
它会释放地址。
或者你可以尝试:
application = server.quick_api(key, secret, 5557)