[問題] 在scrapy shell中,嘗試傳遞cookie失敗

看板Python作者 (黃~)時間7年前 (2018/01/26 19:14), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
大家好,我想在scrapy shell 中測試,selenium登入ptt gossip後,將cookies傳給 Request,最後 view(response),卻出現空白頁,想請問是哪個步驟出錯了,謝謝 空白頁連結>>>https://imgur.com/a/G2tMR 以下是我的代碼 import scrapy from selenium import webdriver from selenium.webdriver.common.by import By from scrapy.http import Request,HtmlResponse driver = webdriver.Chrome(r'C:\Users\Surface\Desktop\scrapy\chromedriver.exe') driver.get("https://www.ptt.cc/ask/over18?from=%2Fbbs%2FGossiping%2Findex.html") driver.get_element(By.XPATH,'.//*[@name="yes"]').click() cookies = driver.get_cookies() request = Request("https://www.ptt.cc/ask/over18?from=%2Fbbs%2FGossiping%2Findex.html") response = HtmlResponse("https://www.ptt.cc/ask/over18?from=%2Fbbs%2FGossiping%2Findex.html",request = request) view(response) 謝謝~ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 120.110.127.195 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1516965240.A.ACA.html
文章代碼(AID): #1QQmruhA (Python)
文章代碼(AID): #1QQmruhA (Python)