Created
December 12, 2020 23:47
-
-
Save MrJoshFisher/186547076206ee90985c0997718ba616 to your computer and use it in GitHub Desktop.
[Beautiful Soup] #bs4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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