Skip to content

Commit

Permalink
Merge pull request #13 from moonlight-aska/covid19-issue199
Browse files Browse the repository at this point in the history
covid19 #199 お知らせのURLが絶対パスの場合の処理を追加
  • Loading branch information
YasushiIS authored May 6, 2020
2 parents 7e28f43 + a2f4e87 commit 2a645f6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scraping_naraNews.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def parse_pref_item(item):
str = item.attrs['href']
str = str.replace('#module', ',')
elem = str.split(',')
url = NARA_PREF_BASE_URL + elem[0]
if elem[0].startswith('http'):
url = elem[0]
else:
url = NARA_PREF_BASE_URL + elem[0]
print(date, url, text)
return date, url, text

Expand Down Expand Up @@ -81,7 +84,9 @@ def parse_city_item(date, title):
# タイトル
text = title.find('a').string
# 相対 → 絶対
url = NARA_CITY_BASE_URL + title.find('a').get('href')
url = title.find('a').get('href')
if not url.startswith('http'):
url = NARA_CITY_BASE_URL + title.find('a').get('href')
print(date, url, text)
return date, url, text

Expand Down

0 comments on commit 2a645f6

Please sign in to comment.