28 lines
759 B
Python
28 lines
759 B
Python
from bs4 import BeautifulSoup
|
|
|
|
with open('./website.txt', 'r', encoding='utf-8') as file:
|
|
file_contents = file.read()
|
|
|
|
soup = BeautifulSoup(file_contents, 'html.parser')
|
|
|
|
name = soup.find('h1').get_text(strip=True)
|
|
print(name)
|
|
|
|
address_spans = soup.find('div', id='exhibitor_details_address').findAll('span')
|
|
address = ""
|
|
for line in address_spans:
|
|
# print(line.get_text())
|
|
address = address + line.get_text() + '\n'
|
|
if address.endswith('\n'):
|
|
address = address[:-1]
|
|
print(address)
|
|
|
|
|
|
link = soup.find('div', id='exhibitor_details_website').find('a').get_text()
|
|
print(link)
|
|
|
|
email = soup.find('div', id='exhibitor_details_email').find('a').get_text()
|
|
print(email)
|
|
|
|
phone = soup.find('div', id='exhibitor_details_phone').find('a').get_text()
|
|
print(phone) |