根据关键词抓取淘宝信息
1,selenium MongoDB PhantomJS .etc
2,一共定义了四个函数:
各自功能如下:
- search_keyword:搜索关键字并返回总页数
- get_infomation:获取单条信息
- next_page:实现翻页效果
- save_to_mongodb:保存到MongoDB
四个函数间,有一定的调用关系。具体参考代码:
附:
#taobao.py
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from selenium import webdriver
import re
from bs4 import BeautifulSoup as bs
from config import *
<