B
B
black_dis2021-09-19 23:48:14
URL Handling
black_dis, 2021-09-19 23:48:14

How to convert site link from mobile version to full version?

I need, having a link to the mobile version of the site, to get a link to the full version of the site.
I tried using requests and passing the user_agent of the PC version, but I didn’t progress further, because I don’t know what to do next with the existing one.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-09-20
@black_dis

If we are talking about links like https://vm.tiktok.com/ZSJoodxLn , then

import requests
r = requests.get('https://vm.tiktok.com/ZSJoodxLn/', headers=headers)
print(r.url)

Where in the headers is the PC user agent. That's enough for tiktok. Or you can block redirects and look at the response to the header location. Some sites redirect using JS on the page, so for the future - it's better to immediately attach the desired link

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question