Pandas 将Str转换为从Beautifulsoup中提取的Datetime
我正在从文章中提取日期,并希望将其存储到MySQL数据库中Pandas 将Str转换为从Beautifulsoup中提取的Datetime,pandas,beautifulsoup,Pandas,Beautifulsoup,我正在从文章中提取日期,并希望将其存储到MySQL数据库中 html = urlopen('https://www.horizont.net/medien/nachrichten/spot-remake-das-ist-der-neue-pick-up-spot-mit-fahri-yardim-und-christian-ulmen-178272') bs = BeautifulSoup(html, 'html.parser') pub = bs.find('span', {'class':
html = urlopen('https://www.horizont.net/medien/nachrichten/spot-remake-das-ist-der-neue-pick-up-spot-mit-fahri-yardim-und-christian-ulmen-178272')
bs = BeautifulSoup(html, 'html.parser')
pub = bs.find('span', {'class':'PublishDate_date'}).get_text()
O要将str转换为datetime,但到目前为止没有任何效果?
你知道怎么解决这个问题吗
这就是输出显示的方式
16. Oktober 2019
如果您的目标是只解析该网站的日期(德语),则可以使用: 安装:
pip install dateparser
样本输出:
>>> dateparser.parse('16. Oktober 2019')
datetime.datetime(2019, 10, 16, 0, 0)
如果您的目标是只解析该网站的日期(德语),则可以使用: 安装:
pip install dateparser
样本输出:
>>> dateparser.parse('16. Oktober 2019')
datetime.datetime(2019, 10, 16, 0, 0)
这与pandas有什么关系?他可能是在使用pandas datetime方法,因为我认为我们需要使用pandas library将其转换为datetime@Horace。输出不适合任何python,因此我不认为有一种干净的方法可以通过标准库进行转换。这是仅用于此页面还是用于其他页面?如何进行转换这与pandas有关吗?他可能在使用pandas datetime方法,因为我认为我们需要使用pandas library将其转换为datetime@Horace。输出不适合任何python,因此我不认为有一种干净的方法可以通过标准库将其转换。这是仅用于此页面还是用于其他页面?谢谢。这很有帮助\谢谢这很有帮助\