-1

This is the code, it took too long to get the data, plus never retrieved the data.

import requests
from bs4 import BeautifulSoup
print("started")
url="https://www.analog.com/en/products.html#"

def get_data(url):
    r=requests.get(url)
    soup=BeautifulSoup(r.text,"html.parser")
    return soup

def parse(soup):
    datas=soup.find_all("div",{"class":"product-row row"})
    print(len(datas))
    return 

print("started")
soup=get_data(url)
print("got data")
parse(soup)
My Work
  • 2,143
  • 2
  • 19
  • 47
Lord_0069
  • 1
  • 2

1 Answers1

0

You will need to provide a User-Agent to you request header, just add

header = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}

at the top of your file and then add the "headers" parameter to your request, as follows

r=requests.get(url,headers=header)

You can read more at this question: How to use Python requests to fake a browser visit a.k.a and generate User Agent?