Is there any solution to get link from the html which has a tag and div tag
html1:
<code><a href="https://u50.ct.sendgrid.net/ls" target="_blank">
<div class="subtitle">
Service request #2226754
</div></a>
</code>
<code><a href="https://u50.ct.sendgrid.net/ls" target="_blank">
<div class="subtitle">
Service request #2226754
</div></a>
</code>
<a href="https://u50.ct.sendgrid.net/ls" target="_blank">
<div class="subtitle">
Service request #2226754
</div></a>
html2:
<code><div class="subtitle">
Service request <a href="https://u5024.ct.sendgrid.net/ls" style="color:#5A88AA; text-decoration:underline;" target="_blank">#2604467</a>
</div>
</code>
<code><div class="subtitle">
Service request <a href="https://u5024.ct.sendgrid.net/ls" style="color:#5A88AA; text-decoration:underline;" target="_blank">#2604467</a>
</div>
</code>
<div class="subtitle">
Service request <a href="https://u5024.ct.sendgrid.net/ls" style="color:#5A88AA; text-decoration:underline;" target="_blank">#2604467</a>
</div>
code:
<code>from bs4 import BeautifulSoup
soup = BeautifulSoup(html, 'html.parser')
scores_string = soup.find("div",text=re.compile(re.compile('Service request',re.IGNORECASE)))
print(scores_string)
ahref = scores_string.find_parent("a")
print(ahref["href"])
Required solutions:
1)https://u50.ct.sendgrid.net/ls
2)https://u5024.ct.sendgrid.net/ls
</code>
<code>from bs4 import BeautifulSoup
soup = BeautifulSoup(html, 'html.parser')
scores_string = soup.find("div",text=re.compile(re.compile('Service request',re.IGNORECASE)))
print(scores_string)
ahref = scores_string.find_parent("a")
print(ahref["href"])
Required solutions:
1)https://u50.ct.sendgrid.net/ls
2)https://u5024.ct.sendgrid.net/ls
</code>
from bs4 import BeautifulSoup
soup = BeautifulSoup(html, 'html.parser')
scores_string = soup.find("div",text=re.compile(re.compile('Service request',re.IGNORECASE)))
print(scores_string)
ahref = scores_string.find_parent("a")
print(ahref["href"])
Required solutions:
1)https://u50.ct.sendgrid.net/ls
2)https://u5024.ct.sendgrid.net/ls
I have two html. Both format are different. I need to take url from both html. Is there any solution using beautifulsoup