您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇文章将为大家详细讲解有关python如何发送json数据,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
具体如下:
# !/usr/bin/env python # -*- coding: utf-8 -*- import urllib2 import urllib import cookielib import json import httplib import re import requests from lxml import etree import StringIO import time s = requests.session() print s.headers login_url = 'http://10.4.161.26:7001/itms/Logon.jsp' data = {'UserID':'015208','Password':'88888888','ScreenWidth':'1600'} # data = urllib.urlencode(data) headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0' } response = s.post(login_url, data=data, headers=headers,timeout=10) print response print '--------------------' print response.status_code print '--------------------' # time.sleep(100) print response.content print response.headers time.sleep(1) myurl='http://10.4.161.26:7001/itms/go?ComponentURL=/Main.view?TWIN=_top","_top' print s.get(myurl).content myurl='http://10.4.161.26:7001/itms/ReportWorkRecord/DailyInputWorkHourDialog.serv' data={"sysHead":{},"appHead":{},"body":{"WORKTYPE":"020","TASKNO":"zhaoyangjian","WORKCONTENT":"zhaoyangjian","WORKHOUR":"10" ,"SERIALNO":"2018112100000106","USERID":"015208","REPORTDATE":"2018/11/21","ACCSTATE":"010","INPUTUSERID" :"015208","INPUTDATE":"2018/11/21","INPUTORGID":"992200402","UPDATEUSERID":"015208","UPDATEDATE":"2018/11/21","UPDATEORGID":"992200402","ISINUSE":"1","SYS_SAVETMP":"","UPDATED_FIELD":"WORKTYPE,TASKNO,WORKCONTENT,WORKHOUR","novalid":'false'}} headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0', 'Content-Type': 'application/json' } print '---------------------------------------------------------' print s.post(myurl, data=json.dumps(data), headers=headers).content
关于“python如何发送json数据”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。