douci2516 2017-01-24 10:21
浏览 84

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

I am on this site https://www.oneness287.com/collections/all/products/adidas-equipment-support-adv-4 and I wish to add the product to my cart.

What I think should work is(x= url of the site)

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

because the form action = "/cart/add" and the input type for size has the name id.

but the response body after this is

&{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>}

What is the correct way to do this?

  • 写回答

1条回答 默认 最新

  • dongzhou4727 2017-01-24 11:40
    关注

    Add URI with base URL

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

    It returns 200 OK

    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题