程序员

京东供应商协同平台 客户评价数据导出python

作者:admin 2021-08-06 我要评论

处理原理 循环打开页面循环逐行展开客户详情读取客户数据写入excel 引用包 import selenium from selenium import webdriver from selenium . webdriver . chrom...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)

处理原理:
循环打开页面,循环逐行展开客户详情读取客户数据写入excel
引用包

import selenium
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import tkinter as tk
from tkinter.filedialog import askdirectory
from lxml import etree
from openpyxl import Workbook
from openpyxl.styles import Font, colors, Alignment
from bs4 import BeautifulSoup
import pandas as pd
import time
import math

Chrom驱动加载:

option = webdriver.ChromeOptions()
# 防止打印一些无用的日志
option.add_experimental_option("excludeSwitches", ['enable-automation', 'enable-logging'])
driver = webdriver.Chrome(chrome_options=option)

循环展开页面数据:

for i in range(10,12):  ##range(10,11)只取第10页,取10~11页 range设置为range(10,12)
        ##beginning 
        js="$($(document.getElementById('clubermindmessage_pager')).find('input')[0]).attr('value',"+str(i)+");$($(document.getElementById('clubermindmessage_pager')).find('input')[1]).click()"
        driver.execute_script(js)
        html=driver.page_source
        soup=BeautifulSoup(html,"lxml")

展开客户详情弹窗:

js="document.getElementsByClassName('td_orderId')["+str(j-1)+"].children[0].click()"
driver.execute_script(js)

取客户数据:

divTag = soup.find_all("div", {"id":"userDetailWinContent"})
            k=0
            for tag in divTag:
                ulTag = tag.find_all("ul")
                for tag in ulTag:
                    liTag = tag.find_all("li")
                    for tag in liTag:
                        spanTag = tag.find_all("span")
                        for tag in spanTag:
                             ##这里写取数逻辑,将数据写入excel
                             k=k+1

关闭客户详情页:

js="document.getElementsByClassName('pui-dialog-titlebar-icon pui-dialog-titlebar-close ui-corner-all')[0].click()"
driver.execute_script(js)

代码获取地址:https://pan.baidu.com/s/1D8Yj_Eg7RM1AWJ_85ZrdJQ

;原文链接:https://blog.csdn.net/fengan1610/article/details/115860219

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
  • 京东供应商协同平台 客户评价数据导出p

    京东供应商协同平台 客户评价数据导出p

  • 有趣python小程序系列之二

    有趣python小程序系列之二

  • 2021第十二届蓝桥杯省赛 python A组 题

    2021第十二届蓝桥杯省赛 python A组 题

  • Python异常的这些知识点你都get到了吗

    Python异常的这些知识点你都get到了吗

腾讯云代理商
海外云服务器