I am new to python crawling. I played with find(tag, attribute = 'value') and found some interesting results.
Here is the code:
from bs4 import BeautifulSoup
html = '''
<a class="cluster_text_headline nclicks(cls_pol.clsart)" href="https://news.naver.com/main/read.nhn?mode=LSD&mid=shm&sid1=100&oid=421&aid=0004679941">text1</a>
<a class="cluster_text_headline nclicks(cls_pol.clsart)" href="https://news.naver.com/main/read.nhn?mode=LSD&mid=shm&sid1=100&oid=032&aid=0003013328">text2</a>
<a class="cluster_text_headline nclicks(cls_pol.clsart)" href="https://news.naver.com/main/read.nhn?mode=LSD&mid=shm&sid1=100&oid=052&aid=0001449034">text3</a>
<a class="cluster_text_headline nclicks(cls_pol.clsart)" href="https://news.naver.com/main/read.nhn?mode=LSD&mid=shm&sid1=100&oid=055&aid=0000819508">text4</a>
<a class="cluster_text_headline nclicks(cls_pol.clsart)" href="https://www.test.com">text5</a>
'''
soup = BeautifulSoup(html, 'html.parser')
a_tags = soup.find('a', href="https://www.test.com")
print(a_tags)
This returns <a class="cluster_text_headline nclicks(cls_pol.clsart)" href="https://www.test.com">text5</a> as expected.
But when I replaced the attribute value in .find(), for example, with 'https://news.naver.com/main/read.nhn?mode=LSD&mid=shm&sid1=100&oid=032&aid=0003013328' (the second link in the code), None is returned. It would be appreciated if anyone can explain why outcomes differ depending on the URL.