Learning Java. Passing the parsing. For the test, I took myself Avito. Tell me how to cope with the phone? The phone is in the form of a picture there, but the problem is solved in the mobile version, but the phone is available only after a click.

When clicking, a GET request is sent:

GET https://m.avito.ru/ufa/gruzoviki_i_spetstehnika/prodayu_kamaz_4510_vezdehod_6h6_samosval_756789406/phone/ba8e8ac080a4dee9323783eb0df8eb55?async 

The block itself:

 <div class="person-actions"> <a rel="nofollow" title="Телефон продавца" href="/ufa/gruzoviki_i_spetstehnika/prodayu_kamaz_4510_vezdehod_6h6_samosval_756789406/phone/ba8e8ac080a4dee9323783eb0df8eb55" class="person-action button button-solid button-blue button-large action-show-number action-link link "> <span class="button-text">Показать номер</span> </a> </div> 

I pull the block like this:

 phone = doc.getElementsByClass("person-actions").select("a").first().html(); 

Thank.


Later:

On the recommendation I tried to pull out the cookies and pull the phone with them, but to no avail. Maybe doing something wrong, correct. Code:

 Connection.Response res = null; res = Jsoup.connect("https://m.avito.ru/ufa/gruzoviki_i_spetstehnika/prodayu_kamaz_4510_vezdehod_6h6_samosval_756789406") .execute(); Document doc = res.parse(); String sessionId = res.cookie("sessid"); System.out.println(sessionId); System.out.println("+++++++++++++++++++++++++++++++++++++++++++"); Document doc2 = Jsoup.connect("https://m.avito.ru/ufa/gruzoviki_i_spetstehnika/prodayu_kamaz_4510_vezdehod_6h6_samosval_756789406/phone/ba8e8ac080a4dee9323783eb0df8eb55?async") .ignoreContentType(true) .cookie("sessid", sessionId) .get(); System.out.println(doc2.toString()); 

The console issues the following:

 01b6fe2d900605a171df7df11847d8d9.1459841297 +++++++++++++++++++++++++++++++++++++++++++ <html> <head></head> <body> {"error":"пожалуйста, обновите страницу"} </body> </html> 
  • Tried to start downloading HTML code for this get request? - Yuriy SPb
  • Yes, I tried. It downloads the same information that the browser displays, namely: {"error":"пожалуйста, обновите страницу"} . Strange somehow, when I enter a line in the address bar of the browser, I get an error like JSON, and when I click the button on the site itself and it sends this request, then in the firewall (network) I get the phone number as JSON - Tryserg
  • If there is no information in the browser, then nothing will be done ( - YuriySPb
  • Added your answer. - Tryserg
  • Here in the network tab, there is information, but it is not clear how to get jsoup or java itself to send this GET request and get an answer {"phone": "1 123 123-12-12"} - Tryserg

0