如何在爬网时从网站写入日期到file.txt

时间:2022-08-24 17:41:16

print str(item['dateUtc']) This is a statement from my code that tries to print date and time. But its not working. The response from the api is

print str(item ['dateUtc'])这是我的代码中的一个声明,它试图打印日期和时间。但它不起作用。来自api的回应是

2015-03-30T00:05:00.000Z

Any Suggestions?

1 个解决方案

#1


0  

something like

import time
def tStamp():
    ts =time.gmtime(time.time())
    return(str(ts.tm_mday)+"["+str(ts.tm_hour)+"."+str(ts.tm_min)+"."+str(ts.tm_sec)+"]/"+str(ts.tm_mon)+"/"+str(ts.tm_year))

is nice to have on deck. alternatively

在甲板上很高兴。或者

def tStamp():
    ts =time.gmtime(time.time())
    return(str(ts.tm_yday)+"["+str(ts.tm_hour)+"."+str(ts.tm_min)+"."+str(ts.tm_sec)+"]/"+str(ts.tm_year))

The documentation here is relevant https://docs.python.org/2/library/time.html

这里的文档是相关的https://docs.python.org/2/library/time.html

as far as the scraping goes I would recommend scrapy over urllib2 ... both are usable.

就刮痧而言,我会建议scll over urllib2 ...两者都可以使用。

#1


0  

something like

import time
def tStamp():
    ts =time.gmtime(time.time())
    return(str(ts.tm_mday)+"["+str(ts.tm_hour)+"."+str(ts.tm_min)+"."+str(ts.tm_sec)+"]/"+str(ts.tm_mon)+"/"+str(ts.tm_year))

is nice to have on deck. alternatively

在甲板上很高兴。或者

def tStamp():
    ts =time.gmtime(time.time())
    return(str(ts.tm_yday)+"["+str(ts.tm_hour)+"."+str(ts.tm_min)+"."+str(ts.tm_sec)+"]/"+str(ts.tm_year))

The documentation here is relevant https://docs.python.org/2/library/time.html

这里的文档是相关的https://docs.python.org/2/library/time.html

as far as the scraping goes I would recommend scrapy over urllib2 ... both are usable.

就刮痧而言,我会建议scll over urllib2 ...两者都可以使用。