花嫁喜铺数据抓取

None.gif private   void  saveImage()
ExpandedBlockStart.gifContractedBlock.gif  
dot.gif {
InBlock.gif   
string baseUri = "http://www.hjxsy.com/hjxp/showimg.asp?id=";
InBlock.gif   
InBlock.gif   
for(int _number = 1; _number < 300; _number ++)
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
try
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     WebClient client 
= new WebClient();
InBlock.gif     client.DownloadFile(baseUri
+_number.ToString(),@"C:\Inetpub\wwwroot\TestWebServices\hj\"+_number.ToString()+".jpg");
ExpandedSubBlockEnd.gif    }

InBlock.gif    
catch
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{}
ExpandedSubBlockEnd.gif   }

ExpandedBlockEnd.gif  }

None.gif  
private   void  saveInfo()
ExpandedBlockStart.gifContractedBlock.gif  
dot.gif {
InBlock.gif   SqlConnection con 
= new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["SqlConnectStringPortal"]);
InBlock.gif   SqlCommand cmd 
= new SqlCommand("insert into marriage values(@id,@name,@priceold,@pricenew,@unit,@intro)",con);
InBlock.gif   cmd.Parameters.Add(
"@id",SqlDbType.Int);
InBlock.gif   cmd.Parameters.Add(
"@name",SqlDbType.NVarChar);
InBlock.gif   cmd.Parameters.Add(
"@priceold",SqlDbType.Money);
InBlock.gif   cmd.Parameters.Add(
"@pricenew",SqlDbType.Money);
InBlock.gif   cmd.Parameters.Add(
"@unit",SqlDbType.NVarChar);
InBlock.gif   cmd.Parameters.Add(
"@intro",SqlDbType.NVarChar);
InBlock.gif   con.Open();
InBlock.gif   
for(int i=1;i<300;i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    
try
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     WebClient client 
= new WebClient();
InBlock.gif     Stream stm 
= client.OpenRead(txtUri.Text+i.ToString());
InBlock.gif     StreamReader sdr 
= new StreamReader(stm,Encoding.Default);
InBlock.gif     
string line = sdr.ReadToEnd();
InBlock.gif
InBlock.gif     
int pm1 = line.IndexOf(@"品名:")+3;
InBlock.gif     
string pm2 = line.Substring(pm1);
InBlock.gif     
int pm3 = pm2.IndexOf(@"</td>");
InBlock.gif     
string _pm = pm2.Substring(0,pm3).Trim();
InBlock.gif
InBlock.gif     
int firstYuan = pm2.IndexOf(@"")+1;
InBlock.gif     
string priceOne = pm2.Substring(firstYuan);
InBlock.gif     
int _firstYuan = priceOne.IndexOf(@" ");
InBlock.gif     
string _priceOne = priceOne.Substring(0,_firstYuan).Trim();
InBlock.gif
InBlock.gif     
string unit = priceOne.Substring(_firstYuan) + 1;
InBlock.gif     
int _unit = unit.IndexOf(@"<br>");
InBlock.gif     
string _unitOne = unit.Substring(0,_unit).Trim();
InBlock.gif
InBlock.gif     
int secondYuan = unit.IndexOf(@"")+1;
InBlock.gif     
string priceTwo = unit.Substring(secondYuan);
InBlock.gif     
int _secondYuan = priceTwo.IndexOf(@" ");
InBlock.gif     
string _priceTwo = priceTwo.Substring(0,_secondYuan).Trim();
InBlock.gif
InBlock.gif     
int intro1 = priceTwo.IndexOf(@"85%")+9;
InBlock.gif     
string intro2 = priceTwo.Substring(intro1);
InBlock.gif     
int intro3 = intro2.IndexOf(@"</td>");
InBlock.gif     
string _intro = intro2.Substring(0,intro3).Replace(@"&nbsp;"," ").Trim();
InBlock.gif
InBlock.gif     cmd.Parameters[
"@id"].Value = i;
InBlock.gif     cmd.Parameters[
"@name"].Value = _pm;
InBlock.gif     cmd.Parameters[
"@priceold"].Value = Convert.ToDecimal(_priceOne);
InBlock.gif     cmd.Parameters[
"@pricenew"].Value = Convert.ToDecimal(_priceTwo);
InBlock.gif     cmd.Parameters[
"@unit"].Value = _unitOne;
InBlock.gif     cmd.Parameters[
"@intro"].Value = _intro;
InBlock.gif     cmd.ExecuteNonQuery();
InBlock.gif     stm.Close();
ExpandedSubBlockEnd.gif    }

InBlock.gif    
catch
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{}
ExpandedSubBlockEnd.gif   }

InBlock.gif   con.Close();
ExpandedBlockEnd.gif  }

None.gif
None.gif
None.gif
None.gif上海热线 
--  wojiehun.com
None.gif
None.gif
None.gif  
private   void  getInfo2()
ExpandedBlockStart.gifContractedBlock.gif  
dot.gif {
InBlock.gif   StreamReader sr 
= new StreamReader(@"C:\Inetpub\wwwroot\TestWebServices\meirong.txt",Encoding.Default);
InBlock.gif   
string line = sr.ReadToEnd();
InBlock.gif   
int flag1;
InBlock.gif   
int flag2;
InBlock.gif   
int flag3;
InBlock.gif   
int flag4;
InBlock.gif   
int flag5;
InBlock.gif   
int flag6;
InBlock.gif   
string str1;
InBlock.gif   
string str2;
InBlock.gif   
string str3;
InBlock.gif   
string str4;
InBlock.gif   
string str5;
InBlock.gif   
string str6;
InBlock.gif   
InBlock.gif   
do
ExpandedSubBlockStart.gifContractedSubBlock.gif   
dot.gif{
InBlock.gif    flag1 
= line.IndexOf(@"http");
InBlock.gif    str1 
= line.Substring(flag1);
InBlock.gif    flag2 
= str1.IndexOf(@"htm")+3;
InBlock.gif    str2 
= str1.Substring(0,flag2);
InBlock.gif
InBlock.gif    flag3 
= str1.IndexOf(@"htm>");
InBlock.gif    str3 
= str1.Substring(flag3);
InBlock.gif    flag4 
= str3.IndexOf(@"</a>");
InBlock.gif    str4 
= str3.Substring(4,flag4);
InBlock.gif
InBlock.gif    WebClient client 
= new WebClient();
InBlock.gif    Stream stm 
= client.OpenRead(str2);
InBlock.gif    StreamReader sdr 
= new StreamReader(stm,Encoding.Default);
InBlock.gif    
string _line = sdr.ReadToEnd();
InBlock.gif    
InBlock.gif    
try
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif     flag5 
= _line.IndexOf(@"<!--enpcontent-->"+17;
InBlock.gif     str5 
= _line.Substring(flag5);
InBlock.gif     flag6 
= str5.IndexOf(@"<script"-1;
InBlock.gif     str6 
= str5.Substring(0,flag6);
InBlock.gif     str6 
= str6.Remove(str6.IndexOf(@"<TABLE"),102);
InBlock.gif
InBlock.gif     
string title = System.Web.HttpUtility.UrlEncode(str4,Encoding.GetEncoding("GB2312"));
InBlock.gif     
string contenttype = System.Web.HttpUtility.UrlEncode("html", Encoding.GetEncoding("GB2312"));
InBlock.gif     
string typeid = System.Web.HttpUtility.UrlEncode("5", Encoding.GetEncoding("GB2312"));
InBlock.gif     
string nfrom = System.Web.HttpUtility.UrlEncode("", Encoding.GetEncoding("GB2312"));
InBlock.gif     
string zznews = System.Web.HttpUtility.UrlEncode("", Encoding.GetEncoding("GB2312"));
InBlock.gif     
string about = System.Web.HttpUtility.UrlEncode("", Encoding.GetEncoding("GB2312"));
InBlock.gif     
string tjnews = System.Web.HttpUtility.UrlEncode("", Encoding.GetEncoding("GB2312"));
InBlock.gif     
string shenghe = System.Web.HttpUtility.UrlEncode("checkbox", Encoding.GetEncoding("GB2312"));
InBlock.gif     
string content = System.Web.HttpUtility.UrlEncode(str6, Encoding.GetEncoding("GB2312"));
InBlock.gif
InBlock.gif     String postStr 
= @"?";
InBlock.gif     postStr 
= postStr + "&title=" + title;
InBlock.gif     postStr 
= postStr + "&contenttype=" + contenttype;
InBlock.gif     postStr 
= postStr + "&typeid=" + typeid;
InBlock.gif     postStr 
= postStr + "&nfrom=" + nfrom;
InBlock.gif     postStr 
= postStr + "&zznews=" + zznews;
InBlock.gif     postStr 
= postStr + "&about=" + about;
InBlock.gif     postStr 
= postStr + "&tjnews=" + tjnews;
InBlock.gif     postStr 
= postStr + "&shenghe=" + shenghe;
InBlock.gif     postStr 
= postStr + "&content=" + content;
InBlock.gif
InBlock.gif     WebClient command 
= new WebClient();
InBlock.gif     Stream st 
= command.OpenRead(postStr);
InBlock.gif     st.Close();
ExpandedSubBlockEnd.gif    }

InBlock.gif    
catch
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{}
InBlock.gif    stm.Close();
InBlock.gif    line 
= str3;
ExpandedSubBlockEnd.gif   }

InBlock.gif   
while(line.Length >93);
ExpandedBlockEnd.gif  }

None.gif
None.gif

转载于:https://www.cnblogs.com/caviare/archive/2007/01/08/615263.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值