爬虫框架Scrapy之模拟登录淘宝

模拟登录淘宝

Selenium+PhantomJS

from selenium import webdriver  
driver = webdriver.PhantomJS()                   
  
driver.get(“https://login.taobao.com/member/login.jhtml“)  
  
driver.find_element_by_id("TPL_username_1").clear()  
driver.find_element_by_id("TPL_password_1").clear()  
driver.find_element_by_id("TPL_username_1").send_keys(self.username)  
driver.find_element_by_id("TPL_password_1").send_keys(self.password)  
  
driver.find_element_by_id("J_SubmitStatic").click()  
  
#driver.get_cookies()取得cookie  
cookie = "; ".join([item["name"] + "=" + item["value"] +"\n" for item in driver.get_cookies()])  
print cookie  
#然后带上cookie登录后的页面去请求页面
    原文作者:whele
    原文地址: https://www.jianshu.com/p/cc060553f79b
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞