爬虫框架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登录后的页面去请求页面

你可能感兴趣的:(爬虫框架Scrapy之模拟登录淘宝)