Skip to content

Instantly share code, notes, and snippets.

@MrJoshFisher
Created December 12, 2020 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrJoshFisher/186547076206ee90985c0997718ba616 to your computer and use it in GitHub Desktop.
Save MrJoshFisher/186547076206ee90985c0997718ba616 to your computer and use it in GitHub Desktop.
[Beautiful Soup] #bs4
#!/usr/bin/python
# Ratings Scraper
# Watches the house price on screetons.
from bs4 import BeautifulSoup
from datetime import datetime
import requests
import re
urls = []
for url in urls:
try:
r = requests.get(url)
xml = r.text
soup = BeautifulSoup(xml, "lxml")
#print soup
ratingsTable = soup.find('div',class_='ratings__table');
#print ratingsTable
ratings = ratingsTable.find_all("div", attrs={"class": "ResultsTableRow"});
for rating in ratings:
#print rating
bName = rating.find('h3', class_='ResultsBusinessName');
bAddress = rating.find('div', class_='ResultsBusinessAddress');
bPostcode = rating.find('div', class_='ResultsBusinessPostcode');
itemLng = rating.find('input', class_='ResultsLongitude');
itemLat = rating.find('input', class_='ResultsLatitude');
ratingValue = rating.find('div', class_='ResultsRatingValue');
ratingImg = ratingValue.find('img').get('alt')
print bName.text.strip(),'|', itemLng.get('value'),'|', itemLat.get('value'), '|',ratingImg, '|', bAddress.text.strip().replace('\r', '').replace('\n', ', ') , ',', bPostcode.text.strip()
# ratingItem = ratingsTable.find_all('div',class_='ResultsTableRow');
#
# rating = ratingItem.find('div',class_='ResultsRatingValue');
#
# print rating
except Exception as e:
print 'Site Error - %s' % (str(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment