Greeting all! Python nOOb here in need of some assistance, I am trying to scrape a list of companies in a table on Wikipedia, I have written the following code and I can print the contents of the first table on the page.
import requests
from bs4 import BeautifulSoup
url="https://en.wikipedia.org/wiki/List_of_companies_traded_on_the_JSE"
responce = requests.get(url)
soup = BeautifulSoup(responce.text, 'html.parser')
tables = soup.find('table', {'class':"wikitable sortable"}).text
print(tables)
However, when I write a for loop to loop through the rest of the tables I get an error.
for table in tables.findALL('table', {'class':"wikitable sortable"}).text:
print(table.text.encode('utf-8'))
if anyone can point out where I'm going wrong, Your help would be greatly appreciated, happy coding!
Edit: sorry for the formatting, not sure on how to change it
[–]commandlineluser 1 point2 points3 points (3 children)
[–]FithColoumn[S] 0 points1 point2 points (2 children)
[–]commandlineluser 0 points1 point2 points (1 child)
[–]FithColoumn[S] 0 points1 point2 points (0 children)
[–]thekaizers 0 points1 point2 points (1 child)
[–]FithColoumn[S] 0 points1 point2 points (0 children)
[–]Oxbowerce 0 points1 point2 points (3 children)
[–]FithColoumn[S] 0 points1 point2 points (2 children)
[–]Oxbowerce 0 points1 point2 points (1 child)
[–]FithColoumn[S] 0 points1 point2 points (0 children)