M
M
MichaelMih2021-07-15 22:39:21
Python
MichaelMih, 2021-07-15 22:39:21

How to understand from the VK link what it is for?

Good afternoon! How can you implement a link type definition and what is it for? So if it is on a post/photo, you need to get the owner id, post id ( photo id ) from the url.

Link examples:

spoiler

https://vk.com/wall-185434489_738132?z=photo-185434489_457345154%2Fwall-185434489_738132 -- photo ( owner_id: -185434489, photo id: 457345154)

https://vk.com/im?sel=253206460&w=wall-151130550_4298586%2F098513c657c2d9a85f -- post ( owner_id: -151130550, post id: 4298586 )

И таких ссылок может быть 10-15 вариаций


My code:
spoiler
if 'wall' in task['url']:
            parsed = urlparse.urlparse(task['url'])
            if 'w' in parse_qs(parsed.query):
                p_url = parse_qs(parsed.query)['w'][0].replace('wall', '').split('_')
            else:
                p_url = parsed.path.replace('wall', '').split('_')
            info['post_id'] = p_url[1]
            info['owner_id'] = p_url[0]


breaks on the first link from the example.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yakovlev Daniil, 2021-07-16
@Kil0Gramm

I didn’t understand your question a little, but I think you are advised to read https://vk.com/dev/wall.post (more other tabs for other links

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question