[問題] selenium 如何告訴PTT我已滿18

看板Python作者 (yshihyu)時間6年前 (2017/10/14 04:10), 編輯推噓3(307)
留言10則, 5人參與, 6年前最新討論串1/1
如何告訴PTT我已滿18並順利抓取八卦版的文章 ? PttName="" load={ 'from':'/bbs/'+PttName+'/index.html', 'yes':'yes' } rs=requests.session() res=rs.post('https://www.ptt.cc/ask/over18',verify=False,data=load) https://www.youtube.com/watch?v=G5MDpnGsE-k
那如果用 selenium 登入八卦版怎麼告知ptt滿18歲? 下面網址是我程式碼跟跑出來結果 https://gist.github.com/anonymous/e1c4f9184af9d6121d86233d86a4cac8 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 175.182.108.87 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1507925446.A.338.html

10/14 04:36, 6年前 , 1F
1. 用已有 cookie 的 profile
10/14 04:36, 1F

10/14 04:37, 6年前 , 2F
2. 點一次 你已經滿 18
10/14 04:37, 2F

10/14 04:48, 6年前 , 3F
find_element_by_xpath() or css()
10/14 04:48, 3F

10/14 04:49, 6年前 , 4F
ActionChains(driver).click(element).perform()
10/14 04:49, 4F

10/14 04:50, 6年前 , 5F
其實我覺得用post就好
10/14 04:50, 5F

10/14 05:29, 6年前 , 6F
rs.post(url,cookies={'over18': '1'})
10/14 05:29, 6F

10/14 05:31, 6年前 , 7F
看錯問題 拍謝
10/14 05:31, 7F

10/14 06:49, 6年前 , 8F
selenium都可以用click了..........
10/14 06:49, 8F

10/14 06:49, 6年前 , 9F
另外用 post 也不難
10/14 06:49, 9F

10/14 13:28, 6年前 , 10F
用 find_element_by_css_selector + click 可以了~感謝
10/14 13:28, 10F
文章代碼(AID): #1PuHt6Cu (Python)