0

I am trying to scrape an attribute from but I must doing something wrong because I cant´t get it.

this is my code

import requests
from bs4 import BeautifulSoup

url = 'https://www.pccomponentes.com/procesadores'

headers = ({'User-Agent':
            'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36',
            'Accept-Language': 'es-ES, es;q=0.5'})

page = requests.get(url,headers=headers)
soup = BeautifulSoup(page.content,'html.parser')
product = soup.find('div',class_ = 'col-xs-6 col-sm-4 col-md-4 col-lg-4')
#print(product)

brand = product.find('a', attrs={'class': 'c-product-card__title-link cy-product-link'})['data-brand']
print(brand)

The target is to obtain "AMD".

Any help would be much appreciate.

Regards

CMonte2
  • 43
  • 4

1 Answers1

1

The following implies that the Cloudflare have detected your requests to the website as an automated bot and subsequently denying you the access to the application.

enter image description here

Because of that you wont find any of your expected information but you may take a look at Python's requests triggers Cloudflare's security while urllib does not

HedgeHog
  • 22,146
  • 4
  • 14
  • 36
  • thanks hedgehog for your comments. If I run the following code: ` brand = product.header.h3.a print(brand) ` It returns the entire text including the data I want and when I scrape the price, product_name, etc, the code runs fine. – CMonte2 Jan 10 '21 at 00:48