Skip to content

Commit

Permalink
Make code conform to PEP-8 style guide
Browse files Browse the repository at this point in the history
  • Loading branch information
simeg committed Aug 14, 2017
1 parent d3235a3 commit 976258c
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions pyhoroscope.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import urllib.request
from lxml import etree


####################################################################
# API
####################################################################

class Horoscope:
def __init__(self):
pass

@staticmethod
def get_todays_horoscope(sunsign):
url = "http://www.ganeshaspeaks.com/horoscopes/daily-horoscope/" + sunsign
response = urllib.request.urlopen(url)
htmlparser = etree.HTMLParser()
tree = etree.parse(response, htmlparser)
html_parser = etree.HTMLParser()
tree = etree.parse(response, html_parser)
date = str(tree.xpath(
"//*[@id=\"daily\"]/div/div[1]/div[1]/div[2]/div/p/text()"))
"//*[@id=\"daily\"]/div/div[1]/div[1]/div[2]/div/p/text()"))
date = date.replace("['", "").replace("']", "").replace("['(", "").replace(")']", "")

horoscope = str(tree.xpath(
"//*[@id=\"daily\"]/div/div[1]/div[2]/p[1]/text()"))
"//*[@id=\"daily\"]/div/div[1]/div[2]/p[1]/text()"))
horoscope = horoscope.replace("[\"\\r\\n ", "").replace(" \\r\\n \\r\\n \"]", "")
horoscope = horoscope.strip()
dict = {
Expand All @@ -32,14 +36,16 @@ def get_todays_horoscope(sunsign):
def get_weekly_horoscope(sunsign):
url = "http://www.ganeshaspeaks.com/horoscopes/weekly-horoscope/" + sunsign
response = urllib.request.urlopen(url)
htmlparser = etree.HTMLParser()
tree = etree.parse(response, htmlparser)
html_parser = etree.HTMLParser()
tree = etree.parse(response, html_parser)
week = str(tree.xpath(
"//*[@id=\"daily\"]/div/div[1]/div[1]/div[2]/div/p/text()"))
week = week.replace("['", "").replace("[u'\\n", "").replace("']", "").replace("\\u2013", "-")
"//*[@id=\"daily\"]/div/div[1]/div[1]/div[2]/div/p/text()"))
week = week.replace("['", "").replace("[u'\\n", "").replace("']", "").replace("\\u2013",
"-")
horoscope = str(tree.xpath(
"//*[@id=\"daily\"]/div/div[1]/div[2]/p[1]/text()"))
horoscope = horoscope.replace("\\r\\n ", "").replace(" \\r\\n ", "").replace(" \\r\\n \\r\\n ", "").replace("['", "").replace("']", "")
"//*[@id=\"daily\"]/div/div[1]/div[2]/p[1]/text()"))
horoscope = horoscope.replace("\\r\\n ", "").replace(" \\r\\n ", "").replace(
" \\r\\n \\r\\n ", "").replace("['", "").replace("']", "")
horoscope = horoscope.strip()
dict = {
'week': week,
Expand All @@ -53,13 +59,14 @@ def get_weekly_horoscope(sunsign):
def get_monthly_horoscope(sunsign):
url = "http://www.ganeshaspeaks.com/horoscopes/monthly-horoscope/" + sunsign
response = urllib.request.urlopen(url)
htmlparser = etree.HTMLParser()
tree = etree.parse(response, htmlparser)
html_parser = etree.HTMLParser()
tree = etree.parse(response, html_parser)
month = str(tree.xpath(
"//*[@id=\"daily\"]/div/div[1]/div[1]/div[2]/div/p/text()"))
month = month.replace("['", "").replace("\\r\\n ", "").replace("['\\n", "").replace("']", "")
"//*[@id=\"daily\"]/div/div[1]/div[1]/div[2]/div/p/text()"))
month = month.replace("['", "").replace("\\r\\n ", "").replace("['\\n", "").replace("']",
"")
horoscope = str(tree.xpath(
"//*[@id=\"daily\"]/div/div[1]/div[2]/p[1]/text()[1]"))
"//*[@id=\"daily\"]/div/div[1]/div[2]/p[1]/text()[1]"))
horoscope = horoscope.replace("\\r\\n ", "").replace("['", "").replace("']", "")
horoscope = horoscope.strip()
dict = {
Expand All @@ -74,14 +81,17 @@ def get_monthly_horoscope(sunsign):
def get_yearly_horoscope(sunsign):
url = "http://www.ganeshaspeaks.com/horoscopes/yearly-horoscope/" + sunsign
response = urllib.request.urlopen(url)
htmlparser = etree.HTMLParser()
tree = etree.parse(response, htmlparser)
html_parser = etree.HTMLParser()
tree = etree.parse(response, html_parser)
year = str(tree.xpath(
"//*[@id=\"daily\"]/div/div[1]/div[1]/div[2]/div/p/text()"))
"//*[@id=\"daily\"]/div/div[1]/div[1]/div[2]/div/p/text()"))
year = year.replace("['", "").replace("['\\n", "").replace("']", "")

horoscope = str(tree.xpath(
"//*[@id=\"daily\"]/div/div[1]/div[2]/p[1]/text()"))
horoscope = horoscope.replace("['\\r\\n ", "").replace(" \\r\\n \\r\\n ", "").replace("[u'", "").replace("']", "").replace("\\xe2\\x80\\x99s", "")
"//*[@id=\"daily\"]/div/div[1]/div[2]/p[1]/text()"))
horoscope = horoscope.replace("['\\r\\n ", "").replace(" \\r\\n \\r\\n ",
"").replace("[u'", "").replace(
"']", "").replace("\\xe2\\x80\\x99s", "")
horoscope = horoscope.strip()
dict = {
'year': year,
Expand Down

0 comments on commit 976258c

Please sign in to comment.