登录到网站,然后张贴到网页中它 [英] Login to a site and then POST to a page in it
问题描述
我登录到使用三个参数的页面,在那之后我有权发布两个参数来我刚刚登录的站点内的另一页。
I have to login to a page using three parameters, after that I have to POST two parameters to another page inside the site I've just logged in.
到目前为止,我已经有了一个cookie与此:
So far I've got a cookie with this:
curl -c cookie.txt -d "username=username&pwd=pwd&domain=mydomain" http://myurl
...饼干里面我有一个JSESSION ID。
我使用cookie如下:
...inside of the cookie I have a JSESSION id. I use the cookie as follows:
curl -b cookie.txt -d "par=value" http://myurlnumbertwo
问题:
- 甚至张贴到登录URL我在控制台中看到登录页面的HTML code后,这是否意味着登录没有成功?我如何才能找到导致这个错误,也许日志?
- 成功登录我怎么留在登录会话和POST我参数到其他网页后?
编辑:
我终于stran的提示后,这方面的工作,遵循code。
I finally got this working after stran's hint, follows the code.
- POST_DATA包含被张贴,如确切的EN codeD字符串'参数1 =值1&放大器;参数2 =值2
- ACTION_URL包含哪些形式发布,如 http://stackoverflow.com/users/login 的完整URL
- POST_DATA contains the exact encoded string that was posted, as in 'parameter1=value1¶meter2=value2'
- ACTION_URL contains the full URL to which the form is posted, as in http://stackoverflow.com/users/login
首先,我做了一个
wget --save-cookie cookie.txt --post-data 'POST_DATA' ACTION_URL
使登录并保存的Cookie,随后是:
to make the login and save the cookie, followed by a:
wget --load-cookie cookie.txt --post-data 'POST_DATA' ACTION_URL
,使我所需要的POST,再次感谢你的提示^^
to make the POST I needed, thank you again for the hint ^^
推荐答案
我给wget的一个尝试。有一个 - 保存 - 饼干
和 - 负载饼干
选项,允许您使用一个Cookie文件。还有处理会话cookie,设施 - 保持会话饼干
。请参考wget的手册页了解更多:)
I'd give wget a try. There is a --save-cookies
and --load-cookies
option that allows you to use a cookie file. There's also a facility for handling session cookies, --keep-session-cookies
. Refer to the wget man page for more :)
就个人而言,我有很多更好的运气通过wget的帖子。
Personally, I've had much better luck with post through wget.
GL!
这篇关于登录到网站,然后张贴到网页中它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!