I'm trying to scrape data from the URL and print out them 1 by 1. Below is my code :
import requests
from bs4 import BeautifulSoup
from pandas import DataFrame
header = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/87.0.4280.88 Safari/537.36 '
}
def scraping(url):
response = requests.get(str(url), headers=header)
soup = BeautifulSoup(response.text, 'html.parser')
table = soup.find('table', {'class': 'stock_details table table-hover table-striped table-theme'})
for listnumber in table.find_all('td', {'class':'number'}):
print(listnumber.get_text())
length = 11
#as output I got has 11 line. But actually I prefer something like 'length = len(listnumber)'
for i in range(len(listnumber)):
print(listnumber[3].get_text())
#expecting value '10,200 / 2,600' would appear
scrapping('https://www.klsescreener.com/v2/stocks/view/5292')
Right now, I only able to print only all the data but still couldn't print them individually. Not only print, but I also plan to use the selected data for some equation later.'
That's why I'm thinking converting those output into array, but it still failed.
Can somebody please help? Thanks a lot!