"/> ">

Home >Web Front-end >HTML Tutorial >【Jsoup】doc.getElementsByTag('img'); Unable to obtain verification code image _html/css_WEB-ITnose

【Jsoup】doc.getElementsByTag('img'); Unable to obtain verification code image _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:44:321429browse

6c04bd5ca3fcae76e30b72ad730ca86d Elements inside

<body class="body">    <div class="headColor">      <div class="headControl">                <img class="image-abclogo" src="https://mobile.abchina.com/mpay/mobileBank/zh_CN/EBusinessModule/image/abclogo.png"></img>              </div>    </div>    <div class="container">        <br />        <h5 class="form-signin-heading">&#x519c;&#x884c;&#x7f51;&#x4e0a;K&#x7801;&#x652f;&#x4ed8;&#xff1a;<br /></h5>        <form method="post" action="/mpay/KCodePaymentCheckAct.ebf">        <label for="inputPassword" class="sr-only">&#x519c;&#x884c;&#x5361;&#x53f7;&#xff1a;</label>        <input type="text" class="form-control" placeholder="请输入卡号" required autofocus style="margin:0px 0px 3px 0px;" name="CardNo"/>        <label for="inputPassword" class="sr-only">&#x624b;&#x673a;&#x53f7;&#x540e;&#x56db;&#x4f4d;&#xff1a;</label>        <input type="text" class="form-control" placeholder="请输入手机号后四位" required autofocus style="margin:0px 0px 3px 0px;" name="MobileNo"/>        <input type="text" id="indentityCode" class="form-control" placeholder="请输入验证码" required style="margin:0px 0px 3px 0px;" name="imageCode" maxlength="4">        <img class="image-indentity pull-right" style="margin:0px 8px 0px 0px;" src="kimageCodeAct.do?random=201504301102343603&ebf_cookie=evniwmih5jg3m4gz4c5uxuch" alt="" />                    <input type="hidden" name="MerchantID" value=""/>         <input type="hidden" name="MerchantName" value="******"/>           <input type="hidden" name="OrderNo" value="J000302015043011025128810001"/>        <input type="hidden" name="OrderAmount" value="3.50"/>        <input type="hidden" name="OrderDate" value="2015/4/30 0:00:00"/>        <input type="hidden" name="OrderTime" value="2015/4/30 11:02:51"/>        <input type="hidden" name="abc_formId" value="9999"/>        <input type="hidden" name="isRead" value="0"/>        <input type="hidden" name="payment" value="1"/>        <input type="hidden" name="TokenTmp" value="14303629533850965238"/>        <input type="hidden" name="payTypeTmp" value="1010"/>        <br />        <button class="btn btn-lg btn-abc btn-block" type="submit" onclick="">确定</button>        <input type="hidden" name="ebf_cookie" value="evniwmih5jg3m4gz4c5uxuch"/></form>        <br /><br />                  <p class="text-center sr-only">m.abchina.com</p>      <p class="text-center sr-only">全国24小时服务热线:95599</p>      <p class="text-center sr-only">中国农业银行版权所有</p>    </div><!-- /.container -->    <p class="text-center">        m.abchina.com<br />        &#x5168;&#x56fd;24&#x5c0f;&#x65f6;&#x670d;&#x52a1;&#x70ed;&#x7ebf;&#xff1a;95599<br />        &#x4e2d;&#x56fd;&#x519c;&#x4e1a;&#x94f6;&#x884c;&#x7248;&#x6743;&#x6240;&#x6709;    </p>    <!-- Bootstrap core JavaScript    ================================================== -->    <!-- Placed at the end of the document so the pages load faster -->    <script src="js/jquery-2.1.3.min.js"></script>    <script src="js/bootstrap.min.js"></script>    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->    <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>  </body>


All elements of this page, a1f02c36ba31691bcfe87b2722de723b can only get
 <img class="image-abclogo" src="https://mobile.abchina.com/mpay/mobileBank/zh_CN/EBusinessModule/image/abclogo.png"></img>

but not
<img class="image-indentity pull-right" style="margin:0px 8px 0px 0px;" src="kimageCodeAct.do?random=201504301102343603&ebf_cookie=evniwmih5jg3m4gz4c5uxuch" alt="" />


Using doc.select("[src]"); cannot get thisa1f02c36ba31691bcfe87b2722de723b


Reply to the discussion (solution )

Is it the 79d7c95122630a3791db16c5259dc98d element that jsoup cannot get the verification code?
I need to get the verification code image here, and the solution I thought of is: get the verification code image 79d7c95122630a3791db16c5259dc98d element, and get its "src",
to get the verification code image.

Is there any other way to get it? Thank you!


No one answered! ! ! !

1. Is the source code you posted copied by the browser or collected and printed by jsoup?

2. If it is copied, please use jsoup to access and print to see if it exists. The img you mentioned

3. According to your description, the img you mentioned does not exist. This img may be generated by js.

4. If it is generated by js, then you need to study the js of this page, and then find the js that generates the url and generate it yourself.

5. After getting the url, you need Note that when requesting this URL, you need to maintain the session of your page, which is the sessionid. Some websites may also have requirements for rf. It is recommended to use Google Chrome to look at all the parameters of the request, and then simulate them all, so Only the obtained verification code may be correct

1. Is the source code you posted copied by the browser or collected and printed by jsoup

2. If it is copied, then please use jsoup access and print to see if the img you mentioned exists

3. According to your description, the img you mentioned should not exist. This img may be generated by js.

4. If it is generated by js, then you need to study the js of this page, and then find the js that generates the url and generate it yourself.

5. After getting the url, you need Note that when requesting this URL, you need to maintain the session of your page, which is the sessionid. Some websites may also have requirements for rf. It is recommended to use Google Chrome to look at all the parameters of the request, and then simulate them all, so Only the verification code obtained may be correct



Thank you for your reply!
Now the problem is solved!
1. The code is collected by jsoup;
3. 4. This img should be generated by js. I couldn't get the js of this page, but I guessed its generation method, and finally got the img;
5. After getting the url, I can directly access the url to the img in the browser. This url has a parameter ebf_cookie, Probably just to keep the conversation going.


I just started using jsoup. Although this problem was solved, I didn't realize at first that this img might be generated by js. Your method of analyzing problems is very good and worth learning. Thank you for your reply! I'm going to tie the knot.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn