Skip to content

Commit

Permalink
Merge branch 'master' into misc
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas0907 committed Apr 15, 2019
2 parents 029c24b + 35a1331 commit 3b4b36c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions feeds/spiders/kurier_at.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def _parse_collection(self, response):
articles = json.loads(response.text)["items"]
for article in articles:
yield scrapy.Request(
"https://efs.kurier.at/api/v1/cfs/route?uri=/kurierat{}".format(
article["url"]
"https://efs.kurier.at/api/v1/cfs/route?uri=/{}{}".format(
article["portal"].replace(".", ""), article["url"]
),
self._parse_article,
meta={
Expand All @@ -106,7 +106,9 @@ def _create_figure(self, src, caption=None):
def _parse_article(self, response):
article = json.loads(response.text)["layout"]["center"][0]
il = FeedEntryItemLoader()
il.add_value("link", urljoin("https://{}".format(self.name), article["url"]))
il.add_value(
"link", urljoin("https://{}".format(article["portal"]), article["url"])
)
il.add_value("title", article["title"])
if "teaser_img" in article:
il.add_value(
Expand Down Expand Up @@ -158,6 +160,7 @@ def _parse_article(self, response):
if not article["authors"]:
il.add_value("author_name", article["agency"])
il.add_value("category", article["channel"]["name"])
il.add_value("category", article["portal"])
il.add_value("path", response.meta["path"])
if article["sponsored"]:
il.add_value("category", "sponsored")
Expand All @@ -182,8 +185,8 @@ def _parse_search(self, response):
articles = json.loads(response.text)["articles"]
for article in articles:
yield scrapy.Request(
"https://efs.kurier.at/api/v1/cfs/route?uri=/kurierat{}".format(
article["url"]
"https://efs.kurier.at/api/v1/cfs/route?uri=/{}{}".format(
article["portal"].replace(".", ""), article["url"]
),
self._parse_article,
meta={
Expand Down

0 comments on commit 3b4b36c

Please sign in to comment.