zoukankan      html  css  js  c++  java
  • 利用 selenium 抓取 淘宝信息

    import lxml
    from bs4 import BeautifulSoup
    import time
    from selenium import webdriver
    import re
    driver = webdriver.PhantomJS()
    driver.set_window_size(1600,20000)
    driver.get("https://item.taobao.com/item.htm?spm=2013.1.0.0.bLyAul&id=17676925595")
    time.sleep(10)
    date=driver.page_source
    soup=BeautifulSoup(date,"lxml")
    shu_liang=re.findall(r'.*title="30天内已售出(d.*?)件',str(soup.select(".tb-sell-counter")))
    color=re.findall(r'<li title="(.*)">颜色分类|li title="(.*)">主要颜色',str(soup.select(".attributes-list")))
    mig="http://"+ re.match(r'.*?(//.*?alicdn.*?)_50x50.jpg',str(soup.select("#J_UlThumb > li > div > a > img"))).group(1)
    daytime=time.strftime('%Y/%m/%d', time.localtime(time.time()))
    leimu=soup.select(".tb-pine")[0].get("data-catid")
    dates=[mig,shu_liang,color,daytime,leimu]
    title=""
    driver.save_screenshot(title.join(re.findall("([u4e00-u9fa5])",driver.title))+".jpg")
    print(dates)
    driver.quit()
  • 相关阅读:
    多线程---同步函数的锁是this(转载)
    函数
    流程控制
    基本语句和运算
    基本数据库类型
    迷宫问题
    Dungeon Master(逃脱大师)-BFS
    HTML元素常用属性整理
    Java_hutool 发起请求
    jQuery Autocomplete
  • 原文地址:https://www.cnblogs.com/gao-xiang/p/6941213.html
Copyright © 2011-2022 走看看