Python开发亚马逊关键词获取工具

提示:此工具基于selenium爬虫框架,故本机必须安装chrome浏览器


前言

这里只贴出了源码,我们公司内部使用时打包成了exe文件,windows电脑可以直接运行,如有需要请下你的邮箱。

后续更新计划:
1.增加其他工具支持,比如JS
2.增加多线程,提高运行效率
3.词频统计,自动生成ST关键词,亚马逊标题,五点描述
4.开发Web版本


提示:以下是本篇文章正文内容,下面案例可供参考

一、项目结构

在这里插入图片描述

一共是五个文件:
  1. Main.py - 主程序
  2. CheckChromeDriver.py - 检查chromedriver版本号
  3. config.json - 配置文件
  4. 要查询的Asin.txt - 放入需要查询的Asin
  5. chromedriver.exe - 爬虫支持程序

二、项目说明

1.Main.py

代码如下:

import os
import xlrd
import xlwt
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support.expected_conditions import presence_of_element_located
from selenium.webdriver.chrome.service import Service
import json
from xlutils.copy import copy
import CheckChromeDriver as ccd

import time

def getKeywordByAsin(asin, pagecount):
    browser.get('https://xp.sellermotor.com/selection/asin-query/query')
    keywordList = []
    # 切换站点
    country = browser.find_element(By.ID, 'search_country_code').get_attribute('data-value')
    if country != countryCode:
        js = '$("#search_country_code").attr("data-value","jp")'
        browser.execute_script(js)
    country = browser.find_element(By.ID, 'search_country_code').get_attribute('data-value')
    print("Current country:", country)
    # 输入Asin
    browser.find_element(By.XPATH, '//*[@id="search-keyword"]').send_keys(asin)
    # 点击查询
    browser.find_element(By.XPATH, '//*[@id="market-insight-search"]').click()
    # element = browser.find_element(By.CLASS_NAME, 'pagination')
    wait.until(presence_of_element_located((By.CLASS_NAME, 'page-item')))
    c = browser.find_elements(By.CLASS_NAME, 'page-item')
    page_count = c[len(c) - 2].text
    if page_count:
        next_click_count = int(page_count)
    else:
        next_click_count = 1
    print(next_click_count)
    title = None
    for i in range(next_click_count):
        if i == pagecount:
            break
        print('------------------Page %s------------------' % (i))
        table = browser.find_element(By.ID, 'asinQueryTable')
        header = table.find_element(By.TAG_NAME, 'thead')
        body = table.find_element(By.TAG_NAME, 'tbody')
        rows = body.find_elements(By.TAG_NAME, 'tr')
        titles = header.find_elements(By.TAG_NAME,</
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值