I have been trying to perform the scrapy exercises in the given article. But, I am not able to find the timestamp in case of Reddit comments. Is there a way through which we can convert the relative time of posts to their actual time directly during the scraping?
You want time from posting date to real time date?
Comment posted on 6 July 2018 and today date is 6 August 2018 so do you need like “comment posted 30 days ago” something?
if you want like this you should use
from datetime import datetime, timedelta item['closing_date'] = item['posting_date'] + DT.timedelta(days=14,hours=23,minutes=59,seconds=59)
I hope this help you
I really appreciate you help.
Actually I have the real time date. I want to extract the posting date and time but it is not mentioned directly in the html code.
Lets take your example,
I am able to extract “30 days ago” but not the actual date 6th july 2018.
How will I extract that date?
I have done same thing in scrapy and code is below:
try: N = int(item['posting_date'].split(" ")) # it will extract day Number item['posting_date'] = datetime.now() - timedelta(days=N) # it will subtract from today's date except: item['posting_date'] = datetime.now()