import requests
from bs4 import BeautifulSoup
url = requests.get(f"https://all-avito.ru/ru/phone/89039123444")
soup = BeautifulSoup(url.content, 'lxml')
for link in soup.find_all('a'):
keys = ["ru/item/"]
for key in keys:
url = link.get("href")
url = f'https://all-avito.ru/{url}'
if key in str(url):
print(url)
import requests
from bs4 import BeautifulSoup
def get_urls(url: str) -> list:
url = requests.get(url)
soup = BeautifulSoup(url.content, 'lxml')
keys = ["ru/item/"]
urls = [
f"https://all-avito.ru/{url}"
for url in map(lambda x: x.get('href'), soup.find_all('a'))
for key in keys if key in str(url)
]
return urls
print(get_urls("https://all-avito.ru/ru/phone/89039123444"))