美团配送cookie设置
This commit is contained in:
@@ -16,6 +16,6 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
api = New("de8157b447584885910f429011e49cb93yjq", "E1D746D42474D5F1F1A10CECE75D99F6", "efa7e1d1a22640fa990e6cf164b28608")
|
||||
api.SetCookieWithStr(`
|
||||
thor=80FAF09E9A09B6E618A68057BDFCFCB88A0E4CE7743FBEC84F10D992F9C6A4119DF98DA3CAAE9C7F17BEB62884625B4E7BC82422A90F45F02EA293572D951B055EF0B5F603AEA568DFD4234138F841EC1AC1F67B30B48AAC9EAD5FBAE7943E1DCC99E99D8358C82F7832B71A2BCB31624E16BBF561720443DE966BDA3588406233A90224D9089710B102AA98B979B9B3;
|
||||
thor=00513FC363111586B2C0E065A90E33C1356AC072AA79A28628FF01BE8B2903995775FF61D2F25840E8BAFB9ED95AF7978DAEDCE30A5A110010D64FEA48F85BB83677488A7432DE90F646CFF6D42A4BAD652ACAF7AE179C5C698CBB31F65EFECCAD53871820D05835E7F794768F7F046E75BE2E9350A2E78AC98970EEB4FCBD6EE51EF9DB61864A5777850F88564E7D42;
|
||||
`)
|
||||
}
|
||||
|
||||
@@ -13,8 +13,14 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
regexpOrderDetailTable = regexp.MustCompile(`<table id="receiveData">([\s\S]*?)</table>`)
|
||||
regexpOrderDetailTd = regexp.MustCompile(`<td colspan="2">(.*?)</td>`)
|
||||
regexpOrderDetailTable = regexp.MustCompile(`<table id="receiveData">([\s\S]*?)</table>`)
|
||||
regexpOrderDetailTd = regexp.MustCompile(`<td colspan="2">(.*?)</td>`)
|
||||
regexpOrderDetailMobile = regexp.MustCompile(`<span id="mobile">(.*?)</span>`)
|
||||
)
|
||||
|
||||
const (
|
||||
JdsOrderDeliverTypeStore = 1274
|
||||
JdsOrderDeleverTypeSelf = 332098
|
||||
)
|
||||
|
||||
func (a *API) AccessStorePage(fullURL string, bizParams map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
|
||||
@@ -369,6 +375,7 @@ func (a *API) AllOrders(allOrdersParam *AllOrdersParam) (allOrdersResult *AllOrd
|
||||
"orderCreateDateRange": allOrdersParam.OrderCreateDateRange,
|
||||
// "storeId": allOrdersParam.StoreID,
|
||||
"orderStatusArray": allOrdersParam.OrderStatusArray,
|
||||
"orderId": allOrdersParam.OrderID,
|
||||
})
|
||||
if err == nil {
|
||||
utils.Map2StructByJson(result, &allOrdersResult, false)
|
||||
@@ -376,23 +383,33 @@ func (a *API) AllOrders(allOrdersParam *AllOrdersParam) (allOrdersResult *AllOrd
|
||||
return allOrdersResult, err
|
||||
}
|
||||
|
||||
type OrderDetailResult struct {
|
||||
ConsigneeName string `json:"consigneeName"`
|
||||
ConsigneeAddress string `json:"consigneeAddress"`
|
||||
ConsigneeMobile string `json:"consigneeMobile"`
|
||||
}
|
||||
|
||||
//订单详情
|
||||
//https://neworder.shop.jd.com/order/orderDetail?orderId=122367441996
|
||||
func (a *API) OrderDetail(orderId string) (consigneeName, consigneeAddress string, err error) {
|
||||
func (a *API) OrderDetail(orderId string) (orderDetailResult *OrderDetailResult, err error) {
|
||||
result, err := a.AccessStorePage("https://neworder.shop.jd.com/order/orderDetail", map[string]interface{}{
|
||||
"orderId": orderId,
|
||||
}, false)
|
||||
if err == nil {
|
||||
orderDetailResult = &OrderDetailResult{}
|
||||
body := result["fakeData"].(string)
|
||||
consigneeTable := regexpOrderDetailTable.FindStringSubmatch(body)
|
||||
fmt.Println("test1", consigneeTable)
|
||||
if len(consigneeTable) > 0 {
|
||||
consigneeTd := regexpOrderDetailTd.FindAllStringSubmatch(consigneeTable[1], -1)
|
||||
consigneeMobiles := regexpOrderDetailMobile.FindStringSubmatch(consigneeTable[1])
|
||||
if len(consigneeTd) > 0 {
|
||||
consigneeName = consigneeTd[0][1]
|
||||
consigneeAddress = consigneeTd[1][1]
|
||||
orderDetailResult.ConsigneeName = consigneeTd[0][1]
|
||||
orderDetailResult.ConsigneeAddress = consigneeTd[1][1]
|
||||
}
|
||||
if len(consigneeMobiles) > 0 {
|
||||
orderDetailResult.ConsigneeMobile = consigneeMobiles[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
return consigneeName, consigneeAddress, err
|
||||
return orderDetailResult, err
|
||||
}
|
||||
|
||||
@@ -58,8 +58,7 @@ func Test11(t *testing.T) {
|
||||
func TestAllOrders(t *testing.T) {
|
||||
result, err := api.AllOrders(&AllOrdersParam{
|
||||
Current: 1,
|
||||
PageSize: 10,
|
||||
StoreID: "24339648",
|
||||
PageSize: 1,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -68,9 +67,9 @@ func TestAllOrders(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOrderDetail(t *testing.T) {
|
||||
result1, result2, err := api.OrderDetail("122367441996")
|
||||
result1, result2, result3, err := api.OrderDetail("122367441996")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmt.Println("test1", result1, result2)
|
||||
fmt.Println("test1", result1, result2, result3)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user