Source: Hi learning network sensitive and eager Forum www.piaodoo.com welcome to learn from each other
This paper describes examples python json data transmission operation. Share to you for your reference, as follows:
# !/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
PS: Here again recommended several more practical json online tool for everyone to use for your reference:
Online JSON code is test, test, landscaping, formatting tools:
http://tools.jb51.net/code/json
JSON online formatting tool:
http://tools.jb51.net/code/jsonformat
Online XML / JSON each other conversion tools:
http://tools.jb51.net/code/xmljson
json Code Online formatting / beautification / compression / editing / converting tool:
http://tools.jb51.net/code/jsoncodeformat
Online json compression / escape tools:
http://tools.jb51.net/code/json_yasuo_trans
More Python-related content and interested readers can view the site topic: "Python operations json skills summary", "Python encoding operation skills summary", "Python data structures and algorithms tutorial", "Python function uses the skills summary", "Python string manipulation techniques to gather "," Python classic introductory and advanced tutorials "and" Python files and directories operating skills summary "
In this paper, we hope that the Python programming help.
The original address is: http: //www.piaodoo.com/thread-13869-1-1.html