Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed to not use relative url
  • Loading branch information
seanmckaybeck committed Aug 18, 2015
1 parent 4466635 commit 32e7f5c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion craigslist/free_stuff_requests.py
Expand Up @@ -18,10 +18,11 @@ def get_args():
return parser.parse_args()


def extract_entry_data(entry):
def extract_entry_data(entry, url):
link = entry.select('a')[0]['href']
submitted = entry.select('time')[0]['datetime']
title = entry.find_all('a', class_='hdrlnk')[0].text
title = '{}{}'.format(url, title)
return {'link': link, 'submitted': submitted, 'title': title}


Expand Down
5 changes: 3 additions & 2 deletions craigslist/free_stuff_requests_parallel.py
Expand Up @@ -24,10 +24,11 @@ def get_args():
return parser.parse_args()


def extract_entry_data(entry):
def extract_entry_data(entry, url):
link = entry.select('a')[0]['href']
submitted = entry.select('time')[0]['datetime']
title = entry.find_all('a', class_='hdrlnk')[0].text
title = '{}{}'.format(url, title)
return {'link': link, 'submitted': submitted, 'title': title}


Expand All @@ -50,7 +51,7 @@ def parse(url):
data = []
start = time.time()
with concurrent.futures.ThreadPoolExecutor(max_workers=count*2) as executor:
res = [executor.submit(extract_entry_data, entry) for entry in entries]
res = [executor.submit(extract_entry_data, entry, url) for entry in entries]
for future in concurrent.futures.as_completed(res):
try:
entry = future.result()
Expand Down

0 comments on commit 32e7f5c

Please sign in to comment.