发布查询淘宝商品的源码!!!!

sy_binbin 2011-01-11 09:26:47
加精
一起返利吧网站,淘宝购物返利上线了,可以搜索你想买的商品是否返利,能返多钱。
http://www.17fanliba.com/taobao.aspx

下面我把里面的一些源码发出来,供大家学习参考!!

前台页面代码:

<asp:TextBox ID="k" runat="server"></asp:TextBox>
<asp:Button ID="Button1"
runat="server" Text="Button" onclick="Button1_Click" />
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<table width="1000" border="0" cellspacing="0" cellpadding="0" class="table-cumore">
<tr>
<td width="132" align="center">
<a href="<%#Eval("click_url") %>" target="_blank">
<img src="<%#Eval("pic_url") %>" alt="<%#Eval("title") %>" height="100" style="border:none;"></a>
</td>
<td width="327" align="left" valign="top">
<a href="<%#Eval("click_url") %>" target="_blank"><b><%#Eval("title") %></b></a>
<br>
掌柜:<a href="<%#Eval("shop_click_url")%>" target="_blank"><%#Eval("nick")%></a> <img src="images/rate-s-<%#Eval("seller_credit_score")%>.gif" />
<br>商品所在地:<%#Eval("item_location") %>
</td>
<td width="117" align="center"><%#Eval("price")%></td>
<td width="143" align="center"><%#GetCommissionRate(decimal.Parse(Eval("commission_rate").ToString()) * Profit)%></td>
<td width="137" align="center"><%#(decimal.Parse(Eval("commission").ToString()) * Profit).ToString("#0.00")%></td>
<td width="142" align="center"><a href="<%#Eval("click_url") %>" target="_blank"><img src="/taobao/images/bijia_4.gif" border="0" /></a></td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
<webdiyer:AspNetPager ID="AspNetPager" runat="server" FirstPageText="首页" LastPageText="尾页"
NextPageText="下一页" OnPageChanged="AspNetPager_PageChanged" PageIndexBoxType="TextBox"
PageSize="15" PrevPageText="上一页" ShowPageIndexBox="Always" SubmitButtonText="Go"
TextAfterPageIndexBox="页" TextBeforePageIndexBox="转到" UrlPaging="True" CenterCurrentPageButton="True" CustomInfoHTML="共%PageCount%页,当前为第%CurrentPageIndex%页,每页%PageSize%条" AlwaysShow="True"> </webdiyer:AspNetPager>


.cs代码:

TaobaoAPI API = new TaobaoAPI();
static string keywordStr = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
keywordStr = Request.QueryString["k"];

if (keywordStr == null)
{

}
else
{
RepeaterListBind(keywordStr);
}

}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("taobaoSearch.aspx?k=" + this.k.Text + "");
}

protected void AspNetPager_PageChanged(object sender, EventArgs e)
{
RepeaterListBind(keywordStr);
}

/// <summary>
/// 绑定搜索出来的商品
/// </summary>
/// <param name="keyword"></param>
protected void RepeaterListBind(string keyword)
{

ITopClient client = new DefaultTopClient(API.apiUrl, API.AppKey, API.AppSecret);

Top.Api.Request.TaobaokeItemsGetRequest req = new Top.Api.Request.TaobaokeItemsGetRequest();

req.Fields = "num_iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume,shop_click_url,seller_credit_score,item_location,volume";
req.Nick = API.nick;
req.Keyword = keyword;
req.Sort = "commissionNum_desc";//排序方式
req.OuterCode = Convert.ToString(Session["memberID"]);//渠道标识
req.PageSize = 40;
req.PageNo = this.AspNetPager.CurrentPageIndex;

int total = 0;//定义 记录总数

Top.Api.Response.TaobaokeItemsGetResponse rsp = client.Execute(req);


string strXml = rsp.Body;//获得XML数据



List<TaobaokeItem> item = new List<TaobaokeItem>();

Parser parser = new Parser();//定义解析XML对象
//ErrorRsp err = new ErrorRsp();//定义错误对象

parser.XmlToObject2<TaobaokeItem>(strXml, "taobaoke_items_get", "taobaoke_items/taobaoke_item", item, err);
total = parser.XmlToTotalResults(strXml, "taobaoke_items_get");

this.AspNetPager.RecordCount = total;

Repeater1.DataSource = item;
Repeater1.DataBind();
}




/// <summary>
/// 获取佣金比例值
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
public string GetCommissionRate(object o)
{
try
{
double rate = Convert.ToDouble(o);
return Convert.ToDouble(rate / 100d).ToString("#0.00") + "%";
}
catch (Exception exp)
{
return o.ToString();
}
}
...全文
6729 255 打赏 收藏 转发到动态 举报
写回复
用AI写文章
255 条回复
切换为时间正序
请发表友善的回复…
发表回复
龙炫 2011-04-20
  • 打赏
  • 举报
回复
值得收藏
b327114069 2011-04-01
  • 打赏
  • 举报
回复
http://www.17fanliba.com/taobao.aspx 楼主啊 。这个跟IE8好像有点不兼容
b327114069 2011-04-01
  • 打赏
  • 举报
回复
http://www.17fanliba.com/taobao.aspx 楼主啊 。这个跟IE8好像有点不兼容
skyaspnet 2011-01-18
  • 打赏
  • 举报
回复
这个和淘宝网是什么关系啊?
再见品月 2011-01-17
  • 打赏
  • 举报
回复

高手作品。。留名观看
lsk_luke 2011-01-17
  • 打赏
  • 举报
回复
各位兄台,我来晚了,下载不了。
我的邮箱是lskhotheart@hotmail.com
哪位兄台给点帮助,发一个.rar。很感谢您。
xingjibing 2011-01-17
  • 打赏
  • 举报
回复
wsleox 2011-01-17
  • 打赏
  • 举报
回复
mark下,下班后研究一下
littlyfx 2011-01-16
  • 打赏
  • 举报
回复
楼主做的不错,以后要是这方面单子还希望与之合作呢
A05125113 2011-01-16
  • 打赏
  • 举报
回复
好强大啊
幻影时空 2011-01-14
  • 打赏
  • 举报
回复
嗯,挺好的,支持一下分享!
clocke 2011-01-14
  • 打赏
  • 举报
回复
嗯,这个好像有点..
Monkey_D_Luffy 2011-01-14
  • 打赏
  • 举报
回复
支持下了子
orlandoluzhao 2011-01-14
  • 打赏
  • 举报
回复
好东西。下次我也上个支付宝的,哈哈。
QQ:21862245 2011-01-14
  • 打赏
  • 举报
回复
欢迎研究淘宝客的朋友加我qq:21862245,大家一起讨论,一起进步。
yrq27 2011-01-14
  • 打赏
  • 举报
回复
我是学jsp滴…………………………………………………………
sx54605628 2011-01-14
  • 打赏
  • 举报
回复
这样的所谓“隐藏”,其实不过是掩耳盗铃,用其他工具还是比较容易看到的。
dtot 2011-01-14
  • 打赏
  • 举报
回复
会不会涉及到商业秘密的哦.
sy_binbin 2011-01-14
  • 打赏
  • 举报
回复
[Quote=引用 218 楼 woainiyibangcui 的回复:]
怎么不能搜索呢?搜索按钮不能点,按回车键会弹出提示“用户名不能为空”,难道搜索还要登录才行?
[/Quote]


这个功能已经加上了!一看你就没好好看
woainiyibangcui 2011-01-14
  • 打赏
  • 举报
回复
怎么不能搜索呢?搜索按钮不能点,按回车键会弹出提示“用户名不能为空”,难道搜索还要登录才行?
加载更多回复(97)

62,051

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧