在scrapy中中了转换时间戳的函数结果报错了什么也没抓取到
在Scrapy中,可以使用Python的time模块来转换时间戳。以下是一个示例代码,可以将时间戳转换为可读的时间格式:
import scrapy
import time
class MySpider(scrapy.Spider):
name = 'my_spider'
start_urls = ['https://example.com']
def parse(self, response):
# 获取时间戳
timestamp = 1612345678
# 转换时间戳为可读的时间格式
readable_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp))
# 打印转换后的时间
print(readable_time)
请确保将timestamp替换为您实际的时间戳,并确认您的爬虫代码中的其他部分是否正确设置。如果您仍然遇到问题,请提供更多的代码和错误消息,以便我们能够更好地帮助您解决问题
原文地址: http://www.cveoy.top/t/topic/iFhW 著作权归作者所有。请勿转载和采集!