D
D
dura2282019-11-03 11:16:07
Python
dura228, 2019-11-03 11:16:07

How to parse phone numbers on olx?

The code

link = 'https://www.olx.ua/uk/obyavlenie/prodam-pdsilyuvach-bampera-hrebet-ford-c-max-hybrid-2013-2017-rk-IDDYHPI.html#7ba85d1008'
    html = requests.get(link).text
    text = re.search("var phoneToken = '[a-zA-Z0-9]+", html)
    token = text.group(0)[18:]
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36',
        'Referer': 'https://www.olx.ua'
    }
    r = requests.get('https://www.olx.ua/uk/ajax/misc/contact/phone/DYHPI/?pt=' + token, headers=headers)
    print(r.text)

returns {"value":"000 000 000"}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny, 2020-04-27
Moykin @moykin_e

Try using a-parser

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question