Check if
If it has do nothing,else add http link.
Eg:
link.get('href')
has http.If it has do nothing,else add http link.
Eg:
from bs4 import BeautifulSoup html = '''\ <a href="http://www.publi24.ro/anunturi/"</a> <a href="/anunturi/imobiliare/de-vanzare/"</a>''' soup = BeautifulSoup(html, 'html.parser') for link in soup.find_all('a'): if 'http' in link.get('href'): print(link.get('href')) else: print('http://www.publi24.ro{}'.format(link.get('href')))
Output:http://www.publi24.ro/anunturi/
http://www.publi24.ro/anunturi/imobiliare/de-vanzare/
Use code tag in your post,i have added it for you now.