<jupyter_start><jupyter_text><jupyter_code><jupyter_output><empty_output><jupyter_text>Exception*try*except*finallyuseful*file i/o*web scraping*databases<jupyter_code>try:
 num1 = int(input("Please input a number? "))
 num2 = int(input("Please input another number"))
 print("Num1 divided by Num2 is" , num1/num2)
except TypeError as e:
  print(e)
except ValueError as e:
  print("Please only type in digits, not letters")
except ZeroDivisionError:
  print("the second number cannot be zero") 
try:
 num1 = int(input("Please input a number? "))
 num2 = int(input("Please input another number"))
 print("Num1 divided by Num2 is" , num1/num2)
except Exception as e: 
 print(e)
 
#if we cant find the error reason:
#There is an error on the following line, need to do more research to work out
#num1 = int(input("Please input a number? "))
num1 = 10
num2 = int(input("Please input another number"))
print("Num1 divided by Num2 is" , num1/num2)<jupyter_output>Please input another number2
Num1 divided by Num2 is 5.0<jupyter_text>Web Scraping Tables* 0. Install any packages need* 1. Import libraries* 2. Setup the URL* 3. Get the webpage* 4. Extract to HTML Important Libraries* urllib, urllib2,urlib3 (powerful, complex)* request(easier and use urllib underneath)* selenium(slow...)<jupyter_code># install requiements
!pip install kora -q

#load packages
from bs4 import BeautifulSoup
from kora.selenium import wd



URL = 'https://www.abs.gov.au/statistics/economy/key-indicators'

#get the page
wd.get(URL)<jupyter_output><empty_output><jupyter_text>Basic HTML Structure                Page Title            This is a Heading    This is a paragraph.          Basic Table Structure                  Company        Contact        Country                    <NAME>        <NAME>        Germany                    Centro comercial Moctezuma        Francisco Chang        Mexico<jupyter_code>soup = BeautifulSoup(wd.page_source,"html.parser")

tables = soup.find_all('table')
len(tables)
tbody = tables[0].find('tbody')
rows = tbody.find_all('tr')

columns = rows[0].find_all('td')
columns[0].text
tables = soup.find_all('table')
for table in tables:
  body = table.find('tbody')
  rows = body.find_all("tr")
  for row in rows:
   data = row.find_all('td')
   for txt in data:
    print(txt.text)
  print()

tables = soup.find_all('table')
#for table in tables:
body = tables[0].find('tbody')
rows = body.find_all("tr")
for row in rows:
  data = row.find_all('td')
  for txt in data:
    print(txt.text)
  print()
# install requiements
!pip install kora -q

#load packages
from kora.selenium import wd
import pandas as pd

# setup the URL
URL = 'https://www.abs.gov.au/statistics/economy/key-indicators'

# Get the page
wd.get(URL)

tables_as_df = pd.read_html(wd.page_source)
len(tables_as_df)
tables_as_df[2]<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup