Answer the question
In order to leave comments, you need to log in
How to parse a site using Ajax?
Hello. There is a task to parse the site www.realestate.ru/flatrent/4275750 , one of the parameters is the owner's phone number, but it is loaded using Ajax. When you click on the "Show phone" button, a post request is sent and in the Network tab in the Response section it only says "OK"
Question: How can I get this phone using Python and requests?
Answer the question
In order to leave comments, you need to log in
See the source of the page, pick up a notepad and a calculator and look for what kind of obsfucation is here.
Specifically, on this site, everything is simple:
Find your line with "Show phone":
We are looking for where these blst , lst1 , lst2 are used and find
function ShowPhones(e)
{
var blst = $(e).attr('blst');
var lst1 = $(e).attr('lst1');
var lst2 = $(e).attr('lst2');
if (blst != "0")
{
$('.object-builder-phone').each(function ()
{
<b>ShowAttr(this, "blst", blst);</b>
...
function ShowAttr(e, attr, value)
{
if ($(e).attr(attr) == "true")
{
var decrypt = value / 17;
var p1 = Math.floor(decrypt / 100);
var p2 = decrypt - 100 * p1;
var t1 = ("" + p1).substring(1) + '-' + pad(p2, 2);
$(e).text($(e).text().replace("...", "") + t1);
$(e).attr(attr, 'false');
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question