Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
url = "http://integrity.ng/index.php/units/browse"
from bs4 import BeautifulSoup
import requests
import csv
# Main Coding Sectio
start = 1
with open("Units.csv", 'wb') as save:
while True:
try:
writer = csv.writer(save, delimiter=',')
nxt = (url + "/"+ str(start))
print (nxt)
r = requests.get(nxt)
soup = BeautifulSoup(r.content, 'html.parser')
table = soup.find("table",{"class": "table table-striped m-b-none"})
table_rows = table.find_all('tr')
for each_row in table_rows[1:]:
row = each_row.get_text()
writer.writerow(row.splitlines())
print((row.splitlines()))
except Exception as e:
print(e)
break
start += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.