import time #时间模块
from bs4 import BeautifulSoup #数据筛选 网页选择器
from selenium import webdriver #测试框架
from selenium.webdriver.support.ui import WebDriverWait #浏览器等待完成的包
#爬虫流程 面向对象
class Taobao_Infos:
#魔术方法 构造方法
def __init__(self):
url = 'https://login.taobao.com/member/login.jhtml'
#self 类属性的作用可以共用
self.url = url
self.broswer = webdriver.Firefox(executable_path='../data/geckodriver.exe')
self.wait = WebDriverWait(self.broswer,10)
#登录 类方法
def login_Infos(self):
#控制浏览器去打开淘宝登录网页
self.broswer.get(self.url,ips)
if self.broswer.find_element_by_xpath('//*[@id="fm-login-id"]'):
user = self.broswer.find_element_by_xpath('//*[@id="fm-login-id"]')
user.send_keys('xxxxxx')
time.sleep(5)
if self.broswer.find_element_by_xpath('//*[@id="fm-login-password"]'):
password = self.broswer.find_element_by_xpath('//*[@id="fm-login-password"]')
password.send_keys('xxxxxx')
time.sleep(6)
submit = self.broswer.find_element_by_xpath('/html/body/div/div[2]/div[3]/div/div/div/div[2]/div/form/div[4]/button')
submit.click()shao
time.sleep(5)
Taobao_Infos().login_Infos()
问题在于,出现了滑动验证,以及submit的xpath出现了错误,
这里我称为易位,针对滑动验证解决思路:1、建立ip池 2、模拟支付宝或者微博登录 针对易位:打算再找点案例
重新学爬虫的第4天
简单笔记用于自己的思路总结,有大佬么求带!