Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-------------------------------------------------------------------------------
- # Name: HTML Web Scraping
- # Purpose:
- #
- # Author: wtgeo_000
- #
- # Created: 07/10/2016
- # Copyright: (c) wtgeo_000 2016
- # Licence: <your licence>
- #-------------------------------------------------------------------------------
- # Import required modules
- from bs4 import BeautifulSoup
- import urllib2
- import csv
- import os
- os.chdir(r'C:\Users\wtgeo_000\Desktop')
- url="http://www.wtamu.edu/student-life/vhac-hours.aspx"
- html = urllib2.urlopen(url).read()
- soup=BeautifulSoup(html, 'html.parser')
- #Create lists for iteration
- rows = soup.findChildren('tr')
- secondhead = soup.findAll(attrs={"class" : "secondhead"})
- secondheadlst = []
- for i in secondhead:
- secondheadlst.append(i.text)
- for row in rows:
- if row.text.strip() in secondheadlst:
- print "########################################################"
- print row.text.strip().upper()
- else:
- print row.text.strip()
- print " "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement