Skip to content Skip to sidebar Skip to footer

How To Clean Up The Data From This Webscraping Script?

So here is my code: import requests from bs4 import BeautifulSoup import lxml r = requests.post('https://opir.fiu.edu/instructor_evals/instr_eval_result.asp', data={'Term': '1175

Solution 1:

Give this a try. I suppose this is what you expected. Btw, if there are more than one tables in that page and if you want another table then twitch the index, as in soup.select('table')[n]. Thanks.

import requests
from bs4 import BeautifulSoup

res = requests.post('https://opir.fiu.edu/instructor_evals/instr_eval_result.asp', data={'Term': '1175', 'Coll': 'CBADM'})
soup = BeautifulSoup(res.text, "lxml")

tables = soup.select('table')[0]
list_items = [[items.text.replace("\xa0","") for items in list_item.select("td")]
                    for list_item in tables.select("tr")] 

for data in list_items:
    print(' '.join(data))

Partial results:

Term:1175-Summer2017Instructor Name:Elias,Desiree   Department:SCHACCOUNTCourse: ACG   2021   Section: RVCC-1 Title:ACCDecisionsEnrolled:118Ref#:51914 -1  Completed Forms:36

Post a Comment for "How To Clean Up The Data From This Webscraping Script?"