changeset 26:585edbea35b1

updating to use of localRequests
author DaveM
date Mon, 30 Apr 2018 14:12:31 +0100
parents a5482a6afe9b
children a94569c4a70b
files V5/synastry.py
diffstat 1 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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: