@aunisyafiqah1310 Thats great!!
Best posts made by saranyaravikumar 0
Latest posts made by saranyaravikumar 0
Hi Auni,
Sorry for the delayed response,
Appreciate your effort in trying web scraping in the sample website.
The problem with your extraction code is that you have not recognised the required children url tag.For example : you can try like this
response=requests.get("https://giftr.my/collections/anniversary ")
soup=bs4.BeautifulSoup(response.text,'html')
title=soup.title
print(title)
productlink=soup.find_all("div",{"class":"mega-sub-link"})
print(productlink)
#Extract the a tag
x=[]
for product1 in productlink:
prdt1=product1.find_all("a")
x.append(prdt1)
print(x)
#Extract the corresponding href
x2=[]
for i in range(len(x)-3):
x1=x[i][0].get('href')
x2.append(x1)
print(x2)
#if you have the parent link append it directly to the child link else add it with the baseurl and produce the child link
baseurl="https://giftr.my/"
childlink=[]
for i in range(0,len(x2)):
if 'https://giftr.my/' in x2[i]:
childlink.append(x2[i])
else:
childlink.append((baseurl+x2[i]))
#Print the child link
childlink
Hope this can resolve your issue in extracting the child link