Home > Software design >  Parenthesis in Python Yield statement
Parenthesis in Python Yield statement

Time:06-16

Im trying to set up a table to display some information on a webpage using yield. I cant get around the parenthesis for grid container so its not returning the whole code. Any way around this using yield? Or do i need another method altogether?

yield " <div > ".encode('utf-8')

I was using a <table> but I didnt like the formatting, so I wanted to try grid-container. Its a webscraper using BeautifulSoup. Here is some of the information going to the table

            yield "<div >".encode('utf-8')
            for div in soup.findAll('div', attrs={'class':"col-md-10"}):
                yield "<tr>".encode('utf-8')
                for name in div.findAll('div', attrs={'name':"label-Address"}):
                     yield "<td>{}</td>".format(name.text).encode('utf-8')
                yield "</tr>".encode('utf-8')
                yield "<tr>".encode('utf-8')
                for name in div.findAll('div', attrs={'name':"label-ScheduledDate"}):
                     yield "<td>{}</td>".format(name.text).encode('utf-8')
                yield "</tr>".encode('utf-8')
                yield "<tr>".encode('utf-8')
                for name in div.findAll('div', attrs={'name':"label-CaseNumber"}):
                     yield "<th>{}</th>".format(name.text).encode('utf-8')

CodePudding user response:

I can see a syntax error as you are using quotes twice, you should correct it like this:

yield " <div class='grid-container'> ".encode('utf-8')
  • Related