Skip to content

Commit

Permalink
Update scraper.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Kooben209 committed Sep 25, 2018
1 parent c9b2996 commit f8084db
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions scraper.py
Expand Up @@ -10,23 +10,23 @@

browser.visit('https://www.rightmove.co.uk/property-for-sale/find.html?locationIdentifier=REGION%5E984&radius=5.0&sortType=18&includeSSTC=true&keywords=probate%2Cexecutor')
time.sleep(10)
if browser.is_element_present_by_xpath('//*[@id="l-searchResults"]/div[29]'):
#if browser.is_element_present_by_xpath('//*[@id="l-searchResults"]/div[29]'):

html = browser.html
soup = BeautifulSoup(html, 'html.parser')
html = browser.html
soup = BeautifulSoup(html, 'html.parser')

searchResults = soup.find("div", {"id" : "l-searchResults"})
matches = 0
if searchResults is not None:
adverts = searchResults.findAll("div", {"id" : lambda L: L and L.startswith('property-')})
for advert in adverts:
if advert.find("div", {"class" : "propertyCard-keywordTag matched"}) is not None:
matches += 1
print("Found "+str(matches)+" Matches from "+str(len(adverts))+" Items")
else:
print('No Search Results\n')
searchResults = soup.find("div", {"id" : "l-searchResults"})
matches = 0
if searchResults is not None:
adverts = searchResults.findAll("div", {"id" : lambda L: L and L.startswith('property-')})
for advert in adverts:
if advert.find("div", {"class" : "propertyCard-keywordTag matched"}) is not None:
matches += 1
print("Found "+str(matches)+" Matches from "+str(len(adverts))+" Items")
else:
print('Page Element Not Found\n')
print('No Search Results\n')
#else:
# print('Page Element Not Found\n')
browser.quit()
sys.exit(0)

0 comments on commit f8084db

Please sign in to comment.