使用爬虫抓取淘宝商品数据
生活随笔
收集整理的這篇文章主要介紹了
使用爬虫抓取淘宝商品数据
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
沒寫完,跟著別人的教程寫的
from bs4 import BeautifulSoup import time from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWaitclass taobao_infos:def __init__(self):url = 'https://login.taobao.com/member/login.jhtml'self.url = urlself.browser = webdriver.Ie(executable_path = r'C:\Users\Administrator\AppData\Local\Programs\Python\Python38\IEDriverServer.exe')self.wait = WebDriverWait(self.browser,10)def login_taobao(self):self.browser.get(self.url)if self.browser.find_element_by_xpath('//*[@id="fm-login-id"]'):user = self.browser.find_element_by_xpath('//*[@id="fm-login-id"]')user.send_keys('cwjcw')time.sleep(3)if self.browser.find_element_by_xpath('//*[@id="fm-login-password"]'):pw = self.browser.find_element_by_xpath('//*[@id="fm-login-password"]')pw.send_keys('weijie81')time.sleep(5)submit = self.browser.find_element_by_xpath('//*[@id="login-form"]/div[4]/button')submit.click()time.sleep(15)search_input = self.browser.find_element_by_xpath('//*[@id="q"]')keyword = input('請輸入:')search_input.send_keys(keyword)search_click = self.browser.find_element_by_xpath('//*[@id="J_TSearchForm"]/div[1]/button')time.sleep(4)search_click.click()taobao_infos().login_taobao()總結
以上是生活随笔為你收集整理的使用爬虫抓取淘宝商品数据的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C++实现黑白棋算法
- 下一篇: 完整的俄罗斯芭蕾课