zoukankan      html  css  js  c++  java
  • 获取淘宝商品描述和价格

    1)价格

    (?<=<strong\\s+[^>]*\"J_StrPrice\"\\s+>)(?<1>[^<]*)(?=</strong>) 

    2)描述 

    分为2步,先获取描述地址,后获取地址内容。 

    (?<=')(?<1>http://dsc.taobaocdn.com.*)(?=')

    取得地址后url 后,请求 http://dsc.taobaocdn.com/url

    (?<=desc=')(?<1>.*)(?=';) 

     代码

     1             Regex reg = new Regex(regExpGoodsDescString);
     2             string tbdescUrl = GetMatchString(reg);
     3             HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(tbdescUrl);
     4             
     5             HttpWebResponse req = (HttpWebResponse)request.GetResponse();
     6             Stream stream = req.GetResponseStream();
     7             StreamReader sr = new StreamReader(stream, Encoding.Default);
     8             string desc = sr.ReadToEnd();
     9 
    10             reg = new Regex("(?<=desc=')(?<1>.*)(?=';)", RegexOptions.Singleline | RegexOptions.Compiled);
    11             return GetMatchString(reg, desc);
  • 相关阅读:
    Linux 配置 nginx + php
    Laravel 网站项目目录结构规划
    配置服务器 Ubuntu 记录+踩坑
    JavaScript 单例,Hash,抛异常
    易理解版八皇后
    获取bing每日图片
    OpenGL 学习笔记 01 环境配置
    [瞎JB写] C++多态
    c++ initialize_list
    最长上升子序列的二分优化
  • 原文地址:https://www.cnblogs.com/lfwolf/p/1907339.html
Copyright © 2011-2022 走看看