Python Forum
Problem with searching over Beautiful Soap object
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with searching over Beautiful Soap object
#10
By using Request and BS you get 200 back,but you have to look content.
There you see that get detected a denned access.
import requests
from bs4 import BeautifulSoup

user_agent = {'User-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.0.0 Safari/537.36'}
url = 'https://www.amazon.com/Advanced-Artificial-Intelligence-Robo-Justice-Georgios-ebook/dp/B0B1H2MZKX/ref=sr_1_1?keywords=9783030982058&qid=1653563461&sr=8-1'
response = requests.get(url, headers=user_agent)
soup = BeautifulSoup(response.content, 'lxml')
title = soup.select_one('#productTitle')
print(response.status_code)
print(title)
print('-' * 20)
print(soup.find('body'))
Output:
200 None -------------------- <body> <!-- To discuss automated access to Amazon data please contact [email protected]. For information about migrating to our APIs refer to our Marketplace APIs at https://developer.amazonservices.com/ref=rm_c_sv, or our Product Advertising API at https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html/ref=rm_c_ac for advertising use cases. --> <!-- Correios.DoNotSend --> .....
Reply


Messages In This Thread
RE: Problem with searching over Beautiful Soap object - by snippsat - May-27-2022, 12:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Beautifull Soap. Split page using a value and not a tag. lillo123 5 3,611 Apr-21-2021, 09:11 AM
Last Post: lillo123
  Beautiful Soap can't find a specific section on the page Pavel_47 1 2,535 Jan-18-2021, 02:18 PM
Last Post: snippsat
  Beautiful soup and tags starter_student 11 6,668 Jul-08-2019, 03:41 PM
Last Post: starter_student
  Beautiful Soup find_all() kirito85 2 3,532 Jun-14-2019, 02:17 AM
Last Post: kirito85
  form.populate_obj problem "object has no attribute translate" pascale 0 3,747 Jun-12-2019, 07:30 PM
Last Post: pascale
  Need help with Beautiful Soup - table jlkmb 9 6,226 Dec-20-2018, 01:10 AM
Last Post: jlkmb
  Type Not Found error on python soap call using suds library wellborn 1 4,738 Dec-19-2017, 07:53 PM
Last Post: micseydel
  Help with beautiful soup Larz60+ 5 4,614 Jul-18-2017, 08:19 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020