from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup
url = '
https://www.amazon.com/s?k=mens+jeans
'
uClient = uReq(url)
the_html =
uClient.read
()
uClient.close()
thesoup = soup(the_html, "html.parser")
linkElems = thesoup.find_all('a',{'class':'a-link-normal a-text-normal'})
for i in range(5):
print(linkElems[i].get('href'))
for whatever reason it's not indenting the last line above, but it should be indented
produces:
/Wrangler-Authentics-Classic-5-Pocket-Regular/dp/B074KL2S4K
/Signature-Levi-Strauss-Gold-Label/dp/B073V3VKCD
/Signature-Levi-Strauss-Gold-Label/dp/B07337GN24
/Signature-Levi-Strauss-Gold-Label/dp/B075CQ65NL
/Wrangler-Authentics-Classic-Relaxed-Military/dp/B074KKZ22D