爬虫数据采集分类
import socket
import threading
server=socket.socket()
server.bind(('0.0.0.0',8000))
server.listen()
def recivee(sock,addr):
while True:
tmp_data=sock.recv(1024).decode('utf8')
print(tmp_data)
def sendd(sock,addr):
while True:
input_data=input().encode('utf8')
sock.send(input_data)
# while True:
sock,addr=server.accept()
t1=threading.Thread(target=recivee,args=(sock,addr))
t2=threading.Thread(target=sendd,args=(sock,addr))
t1.start()
t2.start()
import requests
url="http://127.0.0.1:8000"
params={
"username":"lipei",
"password":"12345"
}
res=requests.get(url,params=params)
print(res)
res.encoding编码
res.status_code状态码