爬取亚马逊商品ipad
- 商品描述
- 评级
- 售价
- 优惠
导入所需要的包
文件格式.ipynb
- 模拟浏览器:webdriver,安装Edge()驱动
- 解析库:pyquery
- 时间模块:time
- pandas
import selenium
from selenium import webdriver
from pyquery import PyQuery as pq
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException,NoSuchElementException
import pandas as pd
import time
import pymongo
页面点击下一页的次数,函数
- 模拟Edge驱动
- 确定搜索框,输入ipad
- 点击搜索
- 获取网页资源,每一页的资源,整体存在列表中
- 找到‘’下一页‘’控件
- 控制窗口右侧滚动条,滚动到最下方,弹窗确定
- 网页加载需要渲染时间,否则页面资源为空,等待10s
def get_page(n):#点击下一页的次数