# HG changeset patch # User DaveM # Date 1525093951 -3600 # Node ID 585edbea35b1ef1e79339b1f2a1d3f07402bf5f9 # Parent a5482a6afe9bd842708906f79ed4fd0b0f954a04 updating to use of localRequests diff -r a5482a6afe9b -r 585edbea35b1 V5/synastry.py --- a/V5/synastry.py Mon Apr 23 12:19:21 2018 +0100 +++ b/V5/synastry.py Mon Apr 30 14:12:31 2018 +0100 @@ -1,7 +1,9 @@ +import sys +sys.path.insert(0,'/Volumes/Internal/Documents/localRequest') import random import csv import re -import requests +import localRequests as lr import time from bs4 import BeautifulSoup @@ -11,7 +13,7 @@ def __init__(self): self.rules = [] self.uniqueID = 0 - print 'Warning, need to fix [Vertex, Ascendant House, South Node, IC/MC and None Location] issues' + print 'Warning, need to fix [Vertex, Ascendant House, IC/MC and None Location] issues' def addRule(self,planetTuple,aspectList,score): rule = compatibilityRule(self.uniqueID,planetTuple,aspectList,score) @@ -214,21 +216,23 @@ 'uhel_orbis':'#tabs_redraw'} def requestURL(self): - self.resp = requests.get(self.url, params=self.payload) - time.sleep(5) + # self.resp = requests.get(self.url, params=self.payload) + self.resp = lr.get(self.url, params=self.payload, timeout=5) + # time.sleep(5) return self.resp def parsePage(self): self.horiscope = None - if('Please use valid date.' in self.resp.content): + # pdb.set_trace() + if('Please use valid date.' in self.resp['content']): self.issue = 'dob' return self.horiscope - elif('Please use valid time.' in self.resp.content): + elif('Please use valid time.' in self.resp['content']): self.issue = 'tob' return self.horiscope gotLocation = 0 self.horiscope = planetPositions() - soup = BeautifulSoup(self.resp.content, 'lxml') + soup = BeautifulSoup(self.resp['content'], 'lxml') tcCell = soup.find_all('div', attrs={'class':'right-sedy-banner-svetlejsi'}) for cell in tcCell: if "Planets in partner's house" in cell.get_text(): @@ -242,12 +246,15 @@ else: self.horiscope.planets[planetName].setLocation(divList[i+2].getText(),divList[i+1].img.attrs['alt'],0) self.horiscope.planets[planetName].setLocation(divList[i+4].getText(),divList[i+3].img.attrs['alt'],1) + if planetName == 'node' + self.horiscope.planets['sNode'].angleA = self.horiscope.planets['node'].angleA+180 + self.horiscope.planets['sNode'].angleB = self.horiscope.planets['node'].angleB+180 return self.horiscope class planetRelation: - noHouseList = ['asc','ic','dsc','mc','asc/mc','sun/moon'] + noHouseList = ['asc','ic','dsc','mc','asc/mc','sun/moon','sNode'] zodiacAngle = {'aries':0,'taurus':30,'gemini':60,'cancer':90,'leo':120,'virgo':150,'libra':180,'scorpio':210,'sagittarius':240,'capricorn':270,'aquarius':300,'pisces':330} def __init__(self,planetName): @@ -281,7 +288,7 @@ aspectRange = {'conjunction':10,'semi-square':2,'sextile':4,'square':10,'trine':10,'opposition':10} # zodiacAngle = {'aries':0,'taurus':30,'gemini':60,'cancer':90,'leo':120,'virgo':150,'libra':180,'scorpio':210,'sagittarius':240,'capricorn':270,'aquarius':300,'pisces':330} # Taken from https://en.wikipedia.org/wiki/Astrological_sign, with reference from https://en.wikipedia.org/wiki/Astrological_symbols#Signs_of_the_zodiac - planetNames = ['sun','moon','mercury','venus','mars','jupiter','saturn','uranus','neptune','pluto','node','lilith','chiron','asc','ic','dsc','mc','asc/mc','sun/moon'] + planetNames = ['sun','moon','mercury','venus','mars','jupiter','saturn','uranus','neptune','pluto','node','sNode','lilith','chiron','asc','ic','dsc','mc','asc/mc','sun/moon'] def __init__(self): self.planets = {} for p in planetPositions.planetNames: