zoukankan      html  css  js  c++  java
  • Python网络编程

    Python网络编程 - http/https网页获取
     
     
     
    用例:
    import socket
     
    def getDataBySocket(url):
        sock = socket.socket()
        ip_port = (url, 80)
        sock.connect(ip_port)
     
        print("建立连接的远程服务器地址:", sock.getpeername())
     
        #发送HPPT请求
        sock.send("GET / HTTP/1.1 ".encode("utf-8"))
        sock.send(("Host: " + url + " ").encode("utf-8"))
        sock.send((" ").encode("utf-8"))
     
        size = 1024
        while True:
            try:
                data = sock.recv(size)
                count = len(data)
                print("读取数据数量:", count)
     
                if count == 0:
                    print("读数据完毕")
                    break
     
                ret = str(data, encoding="utf-8")
                print(ret)
            except BaseException as exc:
                print("发生异常")
                break
     
    if __name__ == '__main__':
        url = "www.baidu.com"
        getDataBySocket(url)
     
     
     
     
    常见端口设置:
    service_list = {
    21:"FTP",
    22:"ssh",
    25:"SMTP",
    80:"web",
    139:"Samba",
    143:"IMAP",
    161:"SNMP",
    389:"Ldap目录访问协议",
    443:"https",
    445:"Microsoft SMB",
    465:"SMTP SSL",
    513:"rlogin",
    546:"DHCP failover",
    873:"rsync",
    993:"IMAPS",
    1080:"socks proxy",
    1194:"OpenVPN",
    1352:"Lotus domino",
    1433:"MSSQL",
    1521:"Oracle default",
    2049:"Nfs",
    2181:"ZooKeeper",
    2375:"Docker",
    3306:"MySQL",
    3389:"Remote Desktop",
    4440:"rundeck",
    4848:"GlassFish控制台",
    5000:"SysBase/DB2",
    5432:"PostgreSQL",
    5632:"pcanywhere",
    5900:"vnc",
    5984:"Apache CouchDB",
    6082:"varnish",
    6984:"Apache CouchDB SSL",
    6379:"Redis",
    7001:"weblogic_Server isten port",
    7002:"Server Listen SSL Port",
    8069:"zabbix",
    8080:"web,jboss,tomcat etc..",
    8089:"Jboss/Tomcat/Resin",
    8083:"influxDB Web admin",
    8086:"influxdb HTTP API",
    8095:"Atlassian Crowd",
    8161:"activemq",
    8888:"Jupyter Notebook",
    8983:"solr",
    9000:"fastcgi",
    9043:"VMware ESXI vsphere",
    9080:"websphere http",
    9083:"Hive default",
    9090:"websphere admin",
    9200:"Elsaticsearch http",
    9300:"Elsaticsearch Node1",
    10000:"HiveServer2",
    11211:"memcached",
    27017:"MongoDB",
    50000:"SAP command excute",
    50060:"hadoop web",
    50070:"hadoop default",
    60000:"HBase Master",
    60010:"hbase.master.info.bindAddress",
    }
  • 相关阅读:
    R语言 主成分分析
    主成分分析(PCA)及其在R里的实现
    UML类图几种关系的总结
    微信Android客户端架构演进之路
    Android单元测试实践
    Android studio 快捷键(Mac)
    Android 启动模式及常用的Intent的Flag
    linux常用命令 (mac ),积少成多
    Android Studio IDE 简单学习和介绍
    轻量级分布式 RPC 框架
  • 原文地址:https://www.cnblogs.com/JacquelineQA/p/13835631.html
Copyright © 2011-2022 走看看