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

    from urllib import  request,parse
    # url='http://www.nnzhp.cn'
    # req=request.urlopen(url) #打开URL,发get请求
    # content=req.read().decode()
    # fw=open('baidu.html','w',encoding='utf-8')
    # fw.write(content)
    #网络爬虫,从其他网站上,获取一些有用的内容(清洗后存到数据库,展示)
    # import json
    # url='http://api.nnzhp.cn/api/user/stu_info?stu_name=xiaohei'
    # req=request.urlopen(url)
    # content=req.read().decode()
    # res_dic=json.loads(content)#返回的结果转成字典
    # if res_dic.get('error_code')==0:
    # print('测试通过')
    # else:
    # print('测试失败',res_dic)

    url='http://api.nnzhp.cn/api/user/login'
    data={
    'username':'admin',
    'passwd':'aA123456'
    }#请求数据
    data=parse.urlencode(data)#urlencode自动拼好参数
    req=request.urlopen(url,data.encode())#发post请求
    print(req.read().decode())
  • 相关阅读:
    mysql总结
    ContOS7 安装 java1.8
    查找
    排序
    线程通信(交替执行)
    死锁(实现)
    Rank Scores
    OpenMP
    聚类的数据量过大的问题
    编译GraphLab出错
  • 原文地址:https://www.cnblogs.com/irisx/p/9053167.html
Copyright © 2011-2022 走看看