如何使用python和beautfulsoup打印每行的时间戳/上次更新时间(来自HTML:)?
如何使用python和beautfulsoup从HTML打印每行的时间戳/上次更新时间?非常感谢 A 1我可以在行后添加打印日期/时间和blast更新时间吗 日期/时间-显示执行python代码的时间 b上次从HTML更新的时间: HTML结构:如何使用python和beautfulsoup打印每行的时间戳/上次更新时间(来自HTML:)?,python,Python,如何使用python和beautfulsoup从HTML打印每行的时间戳/上次更新时间?非常感谢 A 1我可以在行后添加打印日期/时间和blast更新时间吗 日期/时间-显示执行python代码的时间 b上次从HTML更新的时间: HTML结构: td x 1 including two tables each table have few "tr" and within "tr" have few "td" data inside HTML: 以上代码的输出 C Aug-
td x 1 including
two tables
each table have few "tr"
and within "tr" have few "td" data inside
HTML:
以上代码的输出
C Aug-14 - 15000 ; - ; 5 ; 9,904
预期产出:
C Aug-14 - 15000 ; - ; 5 ; 9,904 ; 18/08/2014 ; 13:48:00 ; 18/08/2014 ; 10:19
(execute python code) (last updated time)
要获取代码执行的时间,请执行以下操作:
import datetime from datetime
code_executes = datetime.now()
然后从代码中选择所需的片段,并将其格式化为字符串,以便稍后插入下面的打印语句
要获取最后更新的位,您需要读取顶部表格,因为它没有您指定的id属性,所以您不需要读取顶部表格。如果html只有两个表,那么您可能可以删除beautiful soup的id规范,您将得到两个表
使用str.startswithLast Updated:获取时间,只需抓取字符串片段之后的内容即可
最后,当你打印时,在你的行上钉上两次,这似乎很熟悉。。。
C Aug-14 - 15000 ; - ; 5 ; 9,904 ; 18/08/2014 ; 13:48:00 ; 18/08/2014 ; 10:19
(execute python code) (last updated time)
import datetime from datetime
code_executes = datetime.now()