Last active
August 25, 2018 15:17
-
-
Save Innarticles/940cc3f86764784691dbf4d15c4e35a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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