Skip to content

Commit 93577d6

Browse files
committedNov 20, 2018
Resolve merge conflict
2 parents 268c864 + f5a2b3a commit 93577d6

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed
 

‎Procfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
worker: python3 -m chirps.main --rate=600 --fav --scrape scrape_udacity scrape_coursera scrape_classcentral
1+
worker: python3 -m chirps.main --rate=300 --fav --retweet --follow --scrape scrape_themerkle get_tech_news

‎chirps/functions.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,21 @@ def extract_text(para):
125125
def get_tech_news(): # I'm adventuring with regular expressions for parsing!
126126
"""Finds news for tweeting, along with their links."""
127127
news_block_expr = re.compile(
128-
r'(?s)<a class="story-link".*?href="(.*?)".*?>.*?<h2.*?>(.*?)</h2>.*?'
129-
r'<img.*?src="(.*?)".*?>.*?</a>'
128+
r'(?s)<li.*?a href="(.*?)".*?>.*?<img.*?src="(.*?)".*?>'
129+
r'<h2.*?>(.*?)</h2>.*?</a>'
130130
)
131131
latest_expr = re.compile(
132-
r'(?s)<ol class="story-menu theme-stream initial-set">(.*)</ol>'
132+
r'(?s)<section id="stream-panel".*ol>(.*)</ol>'
133133
)
134134
nyTech = requests.get('https://nytimes.com/section/technology')
135135
latest = latest_expr.search(nyTech.text)
136136
news_blocks = news_block_expr.findall(latest.group(1))
137-
news = []
137+
138138
for i in range(len(news_blocks)):
139139
item = (
140-
news_blocks[i][1].strip() + ' ' + shorten_url(news_blocks[i][0]),
141-
news_blocks[i][2].strip()) # This is img src.
140+
news_blocks[i][2].strip() + ' ' + shorten_url(
141+
'https://nytimes.com'+news_blocks[i][0]),
142+
news_blocks[i][1].strip()) # This is img src.
142143
if item[1].startswith('Daily Report: '):
143144
item = item[14:]
144145
yield item
@@ -238,6 +239,9 @@ def find_news(newsfuncs):
238239

239240
def shorten_url(url):
240241
"""Shortens the passed url using shorte.st's API."""
242+
# QUICK AND DIRTY AND TEMPORARY STUFF:
243+
return url
244+
241245
from chirps.credentials import SHORTE_ST_TOKEN
242246
response = requests.put(
243247
"https://api.shorte.st/v1/data/url",

0 commit comments

Comments
 (0)
Please sign in to comment.