当我单击this页面上的搜索按钮时,它会发送一个post请求。我想通过cli-http来做这篇文章。我该怎么做呢?
(def default-http-opts
{:socket-timeout 10000
:conn-timeout 10000
:insecure? true
:throw-entire-message? false})
(clj-http/post initial-url default-http-opts)我可以发布一个请求,但问题是我想传入一些参数。这些参数(所选按钮)是页面上的默认参数。
它们是:
AdvancedSearchForm:CourseOrSubjectSelection=ALL_ALL
AdvancedSearchForm:GraduateLevelSelection=ALL
AdvancedSearchForm:allStudyAreas=t
AdvancedSearchForm:departmentList=
AdvancedSearchForm:facultyList=
AdvancedSearchForm:keywords=
AdvancedSearchForm:level=ALL
AdvancedSearchForm:semester=ALL
oracle.adf.faces.FORM=AdvancedSearchForm
oracle.adf.faces.STATE_TOKEN=_id21519:_id21520
source=AdvancedSearchForm:searchButton键AdvancedSearchForm:semester包含':',所以我使用字符串作为键,比如"AdvancedSearchForm:semester",在clj-http中可以吗?
我是这样做的:
(spit (file "/tmp" "ts.html")
(:body (http/post initial-url
{:form-params {"AdvancedSearchForm:CourseOrSubjectSelection" "ALL_ALL", "AdvancedSearchForm:GraduateLevelSelection" "ALL"}})))`实际上,它返回的页面确实是“结果”,但没有列出课程。仅模板。我想得到所有的课程链接,这只是手动点击显示。有什么帮助吗?

是我从篡改数据中截取的图像。它显示了我单击Search按钮后发生的事情。客户端似乎被重定向至searchresult.jsp。我使用curl来模仿它。我是这样做的
curl -D "form data..." https://handbook.unimelb.edu.au/faces/htdocs/user/search/AdvancedSearch.jsp
然后快速运行
curl https://handbook.unimelb.edu.au/faces/htdocs/user/search/SearchResults.jsp
下载页面后不会显示结果内容。
发布于 2013-09-08 18:09:20
看起来服务器不理解你发送给它的参数。
使用中的转义是percent-encoding。尝试使用clj-https README.md中提供的调试功能来检查它是否已投入使用:
;; print request info to *out*, including request body:
(client/post "http://example.org" {:debug true :debug-body true :body "..."})或者尝试在终端中使用curl命令或使用方便的Firefox restclient add-on手动运行请求。
发布于 2013-09-07 21:22:26
从他们的GitHub页面(https://github.com/dakrone/clj-http):
;; Send form params as a urlencoded body (POST or PUT)
(client/post "http//site.com" {:form-params {:foo "bar"}})https://stackoverflow.com/questions/18673633
复制相似问题