Exemplo n.º 1
0
def get_price(url):
    content = open_url_str(url)
    soup = BeautifulSoup(content)
    name = soup.find(id = "ga_itemDataBean_description_name").get('value')
    part_num = soup.find(id = "curPartNumber").get('value')
    content = open_url_str(main_url%(part_num))
    factory_send_flag = parse_json_like_str('factorySendFlag',content)
    price = parse_json_like_str('netPrice',content)
    if (factory_send_flag != ''):
        return name, price
    else:
        return name, None
Exemplo n.º 2
0
def get_price(url):
    content = open_url_str(url)
    soup = BeautifulSoup(content)
    r = re.compile('prdInfo = ')
    for script in soup.find_all("script", {"src": False}):
        s = r.search(script.string)
        if s:
            sku_no = parse_json_like_str('skuNo', script.string)
            site_id = parse_json_like_str('siteId', script.string)
            sku_type = parse_json_like_str('skuType', script.string)
            shelf = parse_json_like_str('shelf', script.string)
            sku = parse_json_like_str('sku', script.string)
            prd_id = parse_json_like_str('prdId', script.string)
            program_id = parse_json_like_str('programId', script.string)
            description = parse_json_like_str('description', script.string)
            url = main_url % (sku_no, site_id, sku_type, shelf, sku, prd_id,
                              program_id)
            json = open_url_json(url)
            price1 = json['price']
            result1 = json['result']
            price2 = get_limitbuy_groupon_price(prd_id, sku)
            if (result1 == 'Y'):
                if (price2 != ''):
                    return description, price2
                else:
                    return description, price1
            else:
                return description, None
Exemplo n.º 3
0
def get_price(url):
    content = open_url_str(url)
    soup = BeautifulSoup(content)
    name = soup.findAll("div", {"class" : "p-name"})[0].string
    r = re.compile('pageConfig = ')
    for script in soup.find_all("script", {"src":False}):
        s = r.search(script.string)
        if s:
            skuid = parse_json_like_str('skuid',script.string)
            skuidkey = parse_json_like_str('skuidkey',script.string)
            if get_status(skuidkey)=='有货':
                return name, get_price_key(skuid)
            else:
                return name, None
Exemplo n.º 4
0
Arquivo: jd.py Projeto: zenz34/jiadian
def get_price(url):
    content = open_url_str(url)
    soup = BeautifulSoup(content)
    name = soup.findAll("div", {"class": "p-name"})[0].string
    r = re.compile('pageConfig = ')
    for script in soup.find_all("script", {"src": False}):
        s = r.search(script.string)
        if s:
            skuid = parse_json_like_str('skuid', script.string)
            skuidkey = parse_json_like_str('skuidkey', script.string)
            if get_status(skuidkey) == '有货':
                return name, get_price_key(skuid)
            else:
                return name, None