如何使用golang将产品添加到购物车(post表单)?

如何使用golang将产品添加到购物车(post表单)?,post,go,Post,Go,我在这个网站上,我希望将产品添加到我的购物车中 我认为应该做的是(x=站点的url) 因为表单action=“/cart/add”和大小的输入类型具有名称id 但这之后的反应机构是 &{404 Not Found 404 HTTP/1.1 1 1 map[Date:[Tue, 24 Jan 2017 10:15:39 GMT] X-Dc:[ash,chi2] Content-Type:[text/html; charset=utf-8] Vary:[Accept-Encoding] X-

我在这个网站上,我希望将产品添加到我的购物车中

我认为应该做的是(x=站点的url)

因为表单action=“/cart/add”和大小的输入类型具有名称id

但这之后的反应机构是

&{404 Not Found 404 HTTP/1.1 1 1 map[Date:[Tue, 24 Jan 2017 10:15:39 GMT] X-Dc:[ash,chi2] Content-Type:[text/html; charset=utf-8] Vary:[Accept-Encoding] X-Shardid:[8] X-Permitted-Cross-Domain-Policies:[none] X-Xss-Protection:[1; mode=block; report=/xss-report?source%5Baction%5D=not_found&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=storefront_section%2Fshop&source%5Bsection%5D=storefront&source%5Buuid%5D=66d12b35-aa92-4dea-8add-8fdf04609371] X-Request-Id:[66d12b35-aa92-4dea-8add-8fdf04609371] Connection:[keep-alive] X-Shopid:[1875180] Content-Language:[en] Cache-Control:[no-cache, no-store] Set-Cookie:[customer_sig=; path=/; expires=Sat, 24 Jan 2037 10:15:39 -0000; HttpOnly _session_id=a26d201e2649179d094c504c0edef003; path=/; HttpOnly cart_sig=; path=/; expires=Tue, 07 Feb 2017 10:15:39 -0000; HttpOnly] X-Content-Type-Options:[nosniff] X-Download-Options:[noopen] Server:[nginx]] 0xc042201060 -1 [chunked] false true map[] 0xc0420ae1e0 <nil>}
&{404找不到404 HTTP/1.1映射[Date:[Tue,2017年1月24日10:15:39 GMT]X-Dc:[ash,chi2]内容类型:[text/html;charset=utf-8]变化:[接受编码]X-Shardid:[8]X-Allowed-Cross-Domain-Policys:[none]X-Xss-Protection:[1;mode=block;report=/xss report?source%5Baction%5D=not_found&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=storefront&source%5bauid%5D=66d12b35-aa92-4dea-8add-8fdf04609371]X-Request-Id:[66d12b35-aa92-4dea-8add-8fdf04609371]连接:[-keep-alive]X-Shopid:[187en]缓存控制:[无缓存,无存储]设置Cookie:[customer_sig=;path=/;expires=Sat,2037年1月24日10:15:39-0000;HttpOnly _session_id=a26d201e2649179d094c504c0edef003;path=/;HttpOnly cart_sig=;path=/;expires=Tue,2017年2月7日10:15:39-0000;HttpOnly]X-Content-Type-Options:[nosniff]X-Download-Options:[noopen]Server:[nginx]0xc04201060-1[分块]假-真映射[]0xc0420ae1e0}

正确的方法是什么?

使用base
URL添加
URI

x := "https://www.oneness287.com"
resp, err := http.PostForm(x+"/cart/add",url.Values{"id":{"29709681417"}})

它返回
200 OK

我真的看不出你做了什么不同。请详细说明x现在是URL类型?这有区别吗?@Krash,在你的例子中
x
的值是什么?不要在URL之后使用
/
。因为你在Urial前面添加
/
,检查它们是否支持
http
x := "https://www.oneness287.com"
resp, err := http.PostForm(x+"/cart/add",url.Values{"id":{"29709681417"}})