Hello,
Executing of this code:
How to avoid leading/trailing spaces before/after AI in Cybersecurity (Intelligent Systems Reference Library Book 151) ?
Thanks.
Executing of this code:
import requests from bs4 import BeautifulSoup isbn = 9783319988412 url = f'http://www.amazon.com/s?k={isbn}&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')) url = 'https://www.amazon.com' + a.get('href') print(url) resp = requests.get(url, headers=headers) soup = BeautifulSoup(resp.text, 'lxml') span = soup.find('span', {'id': 'ebooksProductTitle'}) print(span.text)results in this:
Output:/Cybersecurity-Intelligent-Systems-Reference-Library-ebook/dp/B07FKL34B8/ref=sr_1_1?keywords=9783319988412&qid=1574687282&sr=8-1
https://www.amazon.com/Cybersecurity-Intelligent-Systems-Reference-Library-ebook/dp/B07FKL34B8/ref=sr_1_1?keywords=9783319988412&qid=1574687282&sr=8-1
AI in Cybersecurity (Intelligent Systems Reference Library Book 151)
$How to avoid leading/trailing spaces before/after AI in Cybersecurity (Intelligent Systems Reference Library Book 151) ?
Thanks.