import requests from bs4 import BeautifulSoup url = 'http://www.amazon.com/s?k=9783319988412&ref=nb_sb_noss' headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0', 'Accept': 'text/html,*/*', 'Accept-Language': 'en,en-US;q=0.7,en;q=0.3', 'X-Requested-With': 'XMLHttpRequest', 'Connection': 'keep-alive'} resp = requests.get(url, headers=headers) soup = BeautifulSoup(resp.text, 'lxml') # using find a = soup.find('a', {'class': 'a-link-normal a-text-normal'}) print(a.get('href')) # using css selectors a1 = soup.select('a.a-link-normal.a-text-normal') print(a1[0].get('href'))Not sure why you get malformed selector error, but you probably don't want to select using part of the href attribute (would you change the selector for every page?)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs