I'm trying to get the phone from the mobile version, there it is in the text, but to get it you need to click " Show number ". Here is an example.

By clicking on the " Show number " request type https://m.avito.ru/chita/tovary_dlya_detey_i_igrushki/kupi_slona_696014781/phone/fae634b4155194d4b5f7746ce08ecc86?async leaves, but if you try to insert into the tab, you can use your system to find your way to {"error":"пожалуйста, обновите страницу"}

 headers = {'User-Agent' : 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36'} session = requests.session() resp = session.get(url, headers=headers) html = fromstring(resp.content) href = html.xpath(".//*[@class='clearfix']/a[1]/@href")[0] url = urljoin(resp.url, href+'?async') resp = session.get(url) html = fromstring(resp.content) phone = html.xpath(".//*[@class='clearfix']/a[1]/span/text()")[0] 

If you remove ?async , then it simply renders the page with the ad.

Tell me how to pull?

Closed due to the fact that off-topic participants VladD , aleksandr barakin , user194374, Bald , fori1ton 7 Jul '16 at 6:23 .

  • Most likely, this question does not correspond to the subject of Stack Overflow in Russian, according to the rules described in the certificate .
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 3
    Worth a look at the Avito: agreement user agreement . Specifically, paragraph 5.3. By your actions you break it. And without any agreement it would be quite unpleasant that someone would pull the phone out of the ad and use it for their own purposes. And then you sit and wonder where this spam comes from? - m9_psy
  • eight
    The question is aimed at an explicit bypass of the user agreement, and most likely at collecting personal information of participants from a third-party site. I do not think that such issues place on our site. - VladD

1 answer 1

The first thing to look for in such cases is whether HTTP_REFERER is checked. And the guess turns out to be correct:

 wget -o /dev/null -O - \ --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36" \ --referer="https://m.avito.ru/chita/tovary_dlya_detey_i_igrushki/kupi_slona_696014781" \ "https://m.avito.ru/chita/tovary_dlya_detey_i_igrushki/kupi_slona_696014781/phone/fae634b4155194d4b5f7746ce08ecc86?async" 

Voila:

 {"phone":"8 914 456-89-88"} 

Accordingly, you just need to add the Referer field to the headers with the address of the desired page.

  • 2
    It seems to me, it is not necessary to help spammers. - VladD
  • @VladD, the formalities are met and the rays of the diarrhea are sent. But all the same, after all, she will bail ... - PinkTux
  • 2
    @VladD: 1- we do not know whether the author of the question is a spammer. Violation of the user agreement on the conscience of the author of the question, the person who answers the question is not a lawyer and legal advice cannot and should not give. 2- If all protection (if you can call it protection) is the presence of the Referer http header, then you do not need to give your data to similar sites - inevitably such data will be collected regardless of the presence / absence of answers to SO. - jfs
  • 2
    @jfs: If the author of the question asks how to hack a cheap lock, and we start arguing that if the defense of an apartment is built on such a cheap lock, then let the owner fool be robbed - I think we can be called rascals after that. Although yes, formally, we did not do anything bad. - VladD