Learn and live.
URL的格式由三部分组成:第一部分是协议(或称为服务方式)。第二部分是存有该资源的主机IP地址(有时也包括端口号)。第三部分是主机资源的具体地址,如目录和文件名等。
阅读全文
123456789101112131415161718192021222324252627282930313233343536373839
# serverfrom http.server import BaseHTTPRequestHandler, HTTPServerfrom jsonrpcserver import methods@methods.adddef ping(): return('ping')@methods.adddef hao(): return('hao')@methods.adddef hello(name): return('Hello, %s' % name)@methods.adddef Sum(a, b): return(a + b)class TestHttpServer(BaseHTTPRequestHandler): def do_POST(self): # Process request request = self.rfile.read(int(self.headers['Content-Length'])).decode() response = methods.dispatch(request) # Return response self.send_response(response.http_status) self.send_header('Content-type', 'application/json') self.end_headers() self.wfile.write(str(response).encode())if __name__ == '__main__': HTTPServer(('localhost', 5000), TestHttpServer).serve_forever()
我们常说的代理也就是只正向代理,正向代理的过程,它隐藏了真实的请求客户端,服务端不知道真实的客户端是谁,客户端请求的服务都被代理服务器代替来请求,某些科学上网工具扮演的就是典型的正向代理角色。用浏览器访问 http://www.google.com 时,被残忍的block,于是你可以在国外搭建一台代理服务器,让代理帮我去请求google.com,代理把请求返回的相应结构再返回给我.
google.com
正则表达式XPATHbeautifulsouprequestsurlliburllib2scrapy
在/usr/bin目录下一般会存放一个shell脚本,然后在终端输入该shell脚本的名字,就会在终端执行这个shell脚本.1234567891011#!/bin/sh# 搜索进程中touchpanel的进程数目,这里是为了保持脚本执行的单个实例var=`ps -aux |grep "/usr/bin/touchpanel" |wc -l`# 注意空格不能少if [ $var -gt 3 ];then exitficd /opt/touchpanelsudo python3 main.py $@
1234567891011
#!/bin/sh# 搜索进程中touchpanel的进程数目,这里是为了保持脚本执行的单个实例var=`ps -aux |grep "/usr/bin/touchpanel" |wc -l`# 注意空格不能少if [ $var -gt 3 ];then exitficd /opt/touchpanelsudo python3 main.py $@