eddieivan01 / nic Goto Github PK
View Code? Open in Web Editor NEW🌀 Nic is a HTTP request client with elegant and easy-to-use API
License: Mozilla Public License 2.0
🌀 Nic is a HTTP request client with elegant and easy-to-use API
License: Mozilla Public License 2.0
fiddler 抓包信息:
------WebKitFormBoundaryBUZFWBgRBSOaC51N
Content-Disposition: form-data; name="entrustNos"
20190038713
------WebKitFormBoundaryBUZFWBgRBSOaC51N
Content-Disposition: form-data; name="fileList[0].fileName"
request paper
------WebKitFormBoundaryBUZFWBgRBSOaC51N
Content-Disposition: form-data; name="fileList[0].fileRemark"
------WebKitFormBoundaryBUZFWBgRBSOaC51N
Content-Disposition: form-data; name="uploadArr"; filename="38713.pdf"
Content-Type: application/pdf
%PDF-1.3
%
1 0 obj
<<
/Creator (Canon SC1011)
......
用python requests可以这样写:
......
files = {
'entrustNos': [None, '20190038713'],
'fileList[0].fileName': [None, 'request paper'],
'fileList[0].fileRemark': [None, None],
'uploadArr': ['38713.pdf', open('38713.pdf', 'rb'), 'application/pdf']
}
response = rq.post('http://xxx.com', headers=headers, cookies=cookies, files = files)
翻看nic的源码没发现相应的处理方式。
code:
package main
import (
"github.com/eddieivan01/nic"
"log"
"fmt"
)
func post_test(num string){
url := "http://xxx.action?depth=2"
session := &nic.Session{}
resp, err := session.Post(url, nic.H{
Headers: nic.KV{
"Accept": "application/json, text/javascript, */*; q=0.01",
"X-Requested-With": "XMLHttpRequest",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
},
Data: nic.KV{
"$containerNo_like": num,
"page": "1",
"rows": "30",
},
AllowRedirect: true,
})
if err != nil{
log.Println(err.Error())
}
fmt.Println(resp.Text)
}
func main(){
post_test("1234567")
}
结果一直没反应,已经排除服务器问题。
首先感谢作者写的这个库,这是我用过的最舒服的golang http库。
如下Python requests代码:
import requests
cookies = {
'JSESSIONID': '...............',
'nt_pl_cmp_ucode': '..........',
}
headers = {
'Connection': 'keep-alive',
'User-Agent': 'Mozilla/5.0',
.......
}
data = [
...............
('dealPeopleCodes', '01'),
('dealPeopleCodes', '02'),
('dealPeopleCodes', '03'),
('personProCodes', '06'),
('personProCodes', '01'),
('personProCodes', '07'),
('personProCodes', '02'),
('personProCodes', '04'),
('personProCodes', '05'),
.................
]
response = requests.post('https://www.xxx.com/action', headers=headers, cookies=cookies, data=data)
在nic中该如何传递类似Python list类型的数据?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.