0

I am trying web scraping using beautifulsoup. i am trying to get this as the output

<div class="links" data-v-6be015a6=""><a class="card-link" data-v-6be015a6="" href="/istanbul-beylikduzu-cumhuriyet-satilik/daire/93096-835"></a></div>>

how can i cut only the link (istanbul-beylikduzu-cumhuriyet-satilik/daire/93096-835) out of it ?

from bs4 import BeautifulSoup
import requests
import csv

page = 'https://www.hurriyetemlak.com/istanbul-satilik?sortField=PRICE&sortDirection=ASC&p31=200000&p33=1&page=1'
source = requests.get(page).text
    
soup= BeautifulSoup(source, 'html.parser')
link = soup.find('div', attrs = {'class' : 'links'})
print(link)
jottbe
  • 4,228
  • 1
  • 15
  • 31
  • What link would you like to extract? At the first glance I couldn't identify any. – jottbe Nov 29 '20 at 19:53
  • Does this answer your question? [BeautifulSoup getting href](https://stackoverflow.com/questions/5815747/beautifulsoup-getting-href) – MendelG Nov 29 '20 at 21:20

1 Answers1

0

Example - Use ['href']

import bs4

html = '''<div class="links" data-v-6be015a6=""><a class="card-link" data-v-6be015a6="" href="/istanbul-beylikduzu-cumhuriyet-satilik/daire/93096-835"></a></div>>'''

soup = bs4.BeautifulSoup(html)

for a in soup.find_all('a', href=True):
    print( "Found the URL:", a['href'])
HedgeHog
  • 22,146
  • 4
  • 14
  • 36