douwei9759 2017-09-25 14:56
浏览 47
已采纳

如何在不键入的情况下发送用户名和密码?

I want to create an Application (C++) for my schoolmates.

Normally they have to go to our school-website and get to the login site. There, they type their username and password, login and search for their own class.

I want my application to ask them for class, username and password, send it to the timetable site, download the url and print the timetable for them.

I'm only programming C++ so I don't have a problem with all that except the "sending username and password to the site" step. I know the HTML basics so I think i have to search for the variable names used by the site and send them together with the url somehow? I tried some things but I don't understand how that whole thing works.

<label id="username-lbl" for="username" class="required" aria-invalid="false">
"Benutzername"
<span class="star">&nbsp;*</span></label>
<input type="text" name="username" id="username" value class="validate-username required" size="25" required aria-required="true" autofocus>

This is the HTML of the Username field. Do i have to write like

...URL....\index.html&username="theusername" because the id is "username" ? I tried this and it didnt work .. i searched alot on the internet but i dont find an answer.

  • 写回答

2条回答 默认 最新

  • dqwh2717 2017-09-25 15:09
    关注

    Before going any further, check the <form> element's method. The way submitted data is sent changes.

    • If method is GET (or missing), then submitted data is indeed appended to the URL. It is separated from the rest of the URL (as specified by the action attribute) using ? and name-value pairs are separated by &. You also need to properly URL-encode the values.

    • If method is POST, then data is send in the body of the request. The format depends on the enctype.

    Note that there is also the possibility that the data is actually sent using XHR (aka Ajax aka XMLHttpRequest).

    The easiest way to get a feel of how things work is to open the Network tab of the Development tools of your favorite browser. It'll tell you whether it's a regular page or XHR, POST or GET, etc.

    Note that in many cases, the server will then set cookies to keep state, so you'll have to do the same on your side.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题