vendredi 2 avril 2021

WebScraping A Table Doesn't Work With Python Beautiful Soup

I am just starting with web scraping and want to try to scrape the table from this site but when I start with finding the class of the table it doesn't work and instead shows None

Following Is My Code:

from bs4 import BeautifulSoup
import requests
import json

url = 'https://www.nseindia.com/market-data/top-gainers-loosers'
headers = {'User-agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36'}

r = requests.get(url,headers=headers)
soup = BeautifulSoup(r.text,'html.parser')

table = soup.find('table',{'class':'customTable-widthCorp tableWidth-850 '})
print(table)

Following Is The Output Of The Code: Output Image.

How Can I Scrape The Table Contents From The Site?




Aucun commentaire:

Enregistrer un commentaire