BeautifulSoup: get data in class that change name

I’m using BeautifulSoup to scrape an html page where the information I need are stored in a code like this: <a class=" l00_PR_lTitleonContext" href="site0.html"> Title 0 </a> <a class=" l01_PR_lTitleonContext" href="site1.html"> Title 1 </a> <a class=" l02_PR_lTitleonContext" href="site2.html"> Title 2 </a> […] I’d like to get "Title 0", "Title 1" and "Title 2" but the… Read More BeautifulSoup: get data in class that change name

What's wrong with this get method call using BeautifulSoup?

I’m attempting to scrape a web page. When executing this code, it outputs running1 but not running2. Why would this be the case? Code: from time import gmtime, strftime import requests from bs4 import BeautifulSoup import smtplib from email.mime.text import MIMEText print("running1") url = "https://www.johnlewis.com/nordictrack-commercial-14-9-elliptical-cross-trainer/p5639979&quot; response = requests.get(url) print("running2") soup = BeautifulSoup(response.text, ‘lxml’) print("running3") >Solution… Read More What's wrong with this get method call using BeautifulSoup?

Not able to fetch bs4 table contents in python

I want to fetch all the user handles present in this link https://practice.geeksforgeeks.org/leaderboard/ This is the code which tried, import requests from bs4 import BeautifulSoup URL = ‘https://practice.geeksforgeeks.org/leaderboard/&#8217; def getdata(url): r = requests.get(url) return r.text htmldata = getdata(URL) soup = BeautifulSoup(htmldata, ‘html.parser’) table= soup.find_all(‘table’,{"id":"leaderboardTable"}) print(table[0].find_all(‘tbody’)[1]) print(table[0].find_all(‘tbody’)[1].tr) Output: <tbody id="overall_ranking"> </tbody> None The code is fetching… Read More Not able to fetch bs4 table contents in python

How to check if a element/tag exists on page

I am trying to check if a element exists on the webpage with class name of "message message-information", Except when I try I just get a AttributeError: ‘NoneType’. base_name = "GeForce RTX 3070 Ti" url = "https://www.evga.com/products/product.aspx?pn=08G-P5-3797-KL&quot; headers = {"User-Agent": ‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36’} site = requests.get(url,… Read More How to check if a element/tag exists on page