Skip to content

Commit

Permalink
Fixed url cleaning for blogspot archives
Browse files Browse the repository at this point in the history
  • Loading branch information
malnoxon committed Aug 22, 2015
1 parent c3bc02e commit 43fabce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion rsstory/scrapers/siteRules/blogspot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from tld import get_tld
import re
import rsstory.scrapers.tools as tools
import logging

log = logging.getLogger(__name__)

http = urllib3.PoolManager(
cert_reqs='CERT_REQUIRED',
Expand Down Expand Up @@ -40,6 +43,7 @@ def get_monthly_archive_urls(links, page_url):

def get_post_from_month(month_url):
'''Returns the individual posts from the input monthly archive url'''
log.debug("Getting posts from month url: {}".format(month_url))
try:
r = http.request('GET', month_url)
except urllib3.exceptions.SSLError as e:
Expand All @@ -54,7 +58,7 @@ def get_post_from_month(month_url):
post_links = []
for link in links:
try:
url = link.attrs['href']
url = tools.clean_url(link.attrs['href'])
match = url.startswith(tools.clean_url(month_url_base) + year + "/" + month + "/")
if match:
post_links.append(link)
Expand All @@ -63,6 +67,7 @@ def get_post_from_month(month_url):
pass

post_links.reverse() # Reverse the order to get oldest posts first
log.debug("Posts from month url: {} are \n {}".format(month_url, post_links))
return post_links

def remove_duplicates(links):
Expand Down
2 changes: 1 addition & 1 deletion rsstory/scrapers/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def clean_url(url):
'''Removes protocol from url and ensures a trailing slash exists'''
url = url.replace("http://", "").replace("https://", "")
if url[-1] != "/":
url.append("/")
url += "/"

return url

Expand Down

0 comments on commit 43fabce

Please sign in to comment.