作者shancool (酷扇)
看板Python
标题[问题] 爬虫月历range选取
时间Mon Apr 8 10:11:46 2019
Hi 大家好
小弟正在学习爬取钜亨网的新闻 (
https://news.cnyes.com/news/cat/headline?exp=a)
网页是预设11天的新闻 (以今天为例,就预设3/29 - 4/8)
我的问题是:
我是用selenium实作,想要自动选取date range,例如1/1 - 2/28
但不知道如何选取日历range?
目前尝试的方向:
因为有readonly的属性,
我参考了这篇:
https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/447580/
他的code如下:
js = "document.getElementById('c-date1').removeAttribute('readonly')"
driver.execute_script(js)
driver.find_element_by_id('c-date1').send_keys('10/16/2017')
先移除日历readonly的属性,然後才send_keys
但钜亨网中,我不知道这个elemenet的ID,不知道还有甚麽方向可以试看看,
先谢谢各位的帮忙!
<input type = "text" value = "2019/03/29 - 2019/04/08" readonly data-reactid
= "224">
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 101.12.24.215
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1554689510.A.589.html
1F:推 chuchutaro: 用 builtin module 中的 datetime 来做时间操作 04/08 20:37