Answer the question
In order to leave comments, you need to log in
How to parse titles in python?
import urllib.request
from bs4 import BeautifulSoup
def get_html(url):
responce = urllib.request.urlopen(url)
return response.read()
def parse(html):
soup = BeautifulSoup(html, 'html.parser')
table = soup.find('table', cellspacing="1", class_='ipbtable')
for row in table.find_all('tr')[6:]:
cols = row.find_all('td')[2:]
print(cols)
def main():
parse(get_html('site'))
if __name__ == '__main__':
main()
Answer the question
In order to leave comments, you need to log in
and why do you need to search for div separately?
for row in table.find_all('tr')[6:]:
cols = row.find_all('td')[2:]
if cols:
print(cols[0].text)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question