zoukankan      html  css  js  c++  java
  • Splash简单应用

    jd->iphone

    import requests
    from lxml import etree
    #
    search_key = 'iphone'
    jd_url = "https://search.jd.com/Search?keyword={}&enc=utf-8&wq={}&pvid=1a54a615e86645f8aaf828df04a78b27".format(
        search_key, search_key)
    url = 'http://10.63.32.49:8050/render.html?url={}'.format(jd_url)
    print(url)
    # http://10.63.32.49:8050/render.html?url=https://search.jd.com/Search?keyword=iphone&enc=utf-8&wq=iphone&pvid=1a54a615e86645f8aaf828df04a78b27
    r = requests.get(url)
    selector = etree.HTML(r.text)
    li_list = selector.xpath('//div[@id="J_goodsList"]/ul/li')
    for li in li_list:
        price, = li.xpath('.//div[@class="p-price"]//i/text()')
        print(price)
  • 相关阅读:
    day02-数据库操作
    day01-MySQL介绍
    3-socketserver
    1-多线程与多进程
    keyword模块
    math模块
    查看进程pid与ppid
    开启进程的两种方式
    进程理论
    进程
  • 原文地址:https://www.cnblogs.com/wt7018/p/11881357.html
Copyright © 2011-2022 走看看