상대주소와 절대주소
import requests
import lxml.html
url = 'https://www.bobaedream.co.kr/mycar/mycar_list.php?gubun=K'
root = lxml.html.fromstring(res.text)
for link in root.cssselect('.tit a'):
print(link.attrib['href'])
/mycar/mycar_view.php?no=2000784&gubun=K
/mycar/mycar_view.php?no=2016941&gubun=K
/mycar/mycar_view.php?no=2040785&gubun=K
/mycar/mycar_view.php?no=2042393&gubun=K
/mycar/mycar_view.php?no=2042419&gubun=K
/mycar/mycar_view.php?no=2043605&gubun=K
/mycar/mycar_view.php?no=2044290&gubun=K
/mycar/mycar_view.php?no=2036699&gubun=K
/mycar/mycar_view.php?no=2035448&gubun=K
/mycar/mycar_view.php?no=2034639&gubun=K
/mycar/mycar_view.php?no=2045034&gubun=K
/mycar/mycar_view.php?no=2044550&gubun=K
/mycar/mycar_view.php?no=2044551&gubun=K
/mycar/mycar_view.php?no=2044086&gubun=K
/mycar/mycar_view.php?no=2043604&gubun=K
/mycar/mycar_view.php?no=2042420&gubun=K
/mycar/mycar_view.php?no=2041722&gubun=K
/mycar/mycar_view.php?no=2041721&gubun=K
/mycar/mycar_view.php?no=2024905&gubun=K
/mycar/mycar_view.php?no=2040252&gubun=K
from urllib.parse import urljoin
for link in root.cssselect('.tit a'):
print(urljoin(url, link.attrib['href']))
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2000784&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2016941&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2040785&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2042393&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2042419&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2043605&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2044290&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2036699&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2035448&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2034639&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2045034&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2044550&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2044551&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2044086&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2043604&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2042420&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2041722&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2041721&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2024905&gubun=K
https://www.bobaedream.co.kr/mycar/mycar_view.php?no=2040252&gubun=K