I'm trying to scrape a website but my BeautifulSoup returns: 'NoneType' object has no attribute 'get_text'
. However, the element does exist.
Here is my code:
headers = {'User-Agent': 'Mozilla/5.0'}
response = requests.get(url, headers=headers)
#time.sleep(60)
soup = BeautifulSoup(response.content, 'html.parser')
NumArticle = url.split('/')[-2]
titreArticle = soup.find("h1", {"class":"wi-article-title article-title-main"}).get_text()
I used the: headers = {'User-Agent': 'Mozilla/5.0'} response = requests.get(url, headers=headers)
because otherwise I would get a 403 error.
And I tried to use a time.sleep(x)
because I saw on a forum that it could solve the problem but in my case it didn't work.
Do you have any idea how I could solve this problem?