亲。。。这个估计5分钟都用不上。。。两分钟吧。。关键是QQ会员。。。我去,,一楼的太没节操了!!!
求楼主,加好友。。你@ 我,,,,我帮你做整个网站爬虫。。程序,,你要什么功能我帮你写什么功能!!
切。。鄙视一楼!!
丫。找事儿?
@哇~怪兽: 围观……
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace GenURL_01 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } string srcPath; private void button1_Click(object sender, EventArgs e) { OpenFileDialog opd = new OpenFileDialog(); opd.Filter = "Text files(*.txt)|*.txt"; opd.RestoreDirectory = true; if (opd.ShowDialog() == DialogResult.OK) { srcPath = opd.FileName; textBox1.Text = srcPath; } } public void WriteToTxt(string s) { //实例化一个文件流--->与写入文件相关联 string path = srcPath; if (!File.Exists(path)) { File.Create(path); } FileStream fs = new FileStream(path, FileMode.Append); //实例化一个StreamWriter-->与fs相关联 StreamWriter sw = new StreamWriter(fs); //开始写入 sw.WriteLine(s); //清空缓冲区 sw.Flush(); //关闭流 sw.Close(); fs.Close(); } private void button2_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox1.Text)) { MessageBox.Show("路径不能为空!"); return; } if (string.IsNullOrEmpty(textBox2.Text)) { MessageBox.Show("前字段不能为空!"); return; } if (string.IsNullOrEmpty(textBox3.Text)) { MessageBox.Show("开始值不能为空!"); return; } if (string.IsNullOrEmpty(textBox4.Text)) { MessageBox.Show("结束值不能为空!"); return; } button2.Enabled = false; int start = int.Parse(textBox3.Text); int end = int.Parse(textBox4.Text); for (int i = start; i <= end; i++) { WriteToTxt(textBox2.Text+i); if (i % 37 == 0) { label5.Text = "写入" + (i - start - 1) + "条"; label5.Refresh(); } } label5.Text = "共输出"+(end-start+1)+"条.\r\n至文件:"+srcPath; button2.Enabled = true; } } }
上面是Form1.cs 的内容
后台.designer 内容
namespace GenURL_01 { partial class Form1 { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// 清理所有正在使用的资源。 /// </summary> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// </summary> private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.textBox1 = new System.Windows.Forms.TextBox(); this.button2 = new System.Windows.Forms.Button(); this.textBox2 = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.textBox3 = new System.Windows.Forms.TextBox(); this.textBox4 = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(391, 29); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(53, 23); this.button1.TabIndex = 0; this.button1.Text = "浏览"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(74, 31); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(311, 21); this.textBox1.TabIndex = 1; // // button2 // this.button2.Location = new System.Drawing.Point(325, 197); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(60, 23); this.button2.TabIndex = 2; this.button2.Text = "生成"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // textBox2 // this.textBox2.Location = new System.Drawing.Point(12, 102); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(432, 21); this.textBox2.TabIndex = 3; this.textBox2.Text = "http://www.ocj.com.cn/shop/newshop.jsp?seq_shop_num="; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(13, 84); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(41, 12); this.label1.TabIndex = 4; this.label1.Text = "前字段"; // // textBox3 // this.textBox3.Location = new System.Drawing.Point(65, 150); this.textBox3.Name = "textBox3"; this.textBox3.Size = new System.Drawing.Size(62, 21); this.textBox3.TabIndex = 5; // // textBox4 // this.textBox4.Location = new System.Drawing.Point(156, 150); this.textBox4.Name = "textBox4"; this.textBox4.Size = new System.Drawing.Size(65, 21); this.textBox4.TabIndex = 6; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(13, 153); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(41, 12); this.label2.TabIndex = 7; this.label2.Text = "值 从"; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(133, 153); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(17, 12); this.label3.TabIndex = 8; this.label3.Text = "到"; // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(15, 39); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(53, 12); this.label4.TabIndex = 9; this.label4.Text = "文件路径"; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(15, 202); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(0, 12); this.label5.TabIndex = 10; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(456, 241); this.Controls.Add(this.label5); this.Controls.Add(this.label4); this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.textBox4); this.Controls.Add(this.textBox3); this.Controls.Add(this.label1); this.Controls.Add(this.textBox2); this.Controls.Add(this.button2); this.Controls.Add(this.textBox1); this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.Button button1; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Button button2; private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox textBox3; private System.Windows.Forms.TextBox textBox4; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label5; } }
这位仁兄。请组织好自己的语言
是要 域名/1 就在网站上生成1.txt文件么 ?
是这样的 拿京东举例 http://item.jd.com/768575.html 单品页是这样的,我想用
http://item.jd.com/1.html http://item.jd.com/2.html
一直到 http://item.jd.com/768575.html
生成之后 在txt文本里就可以
@张少: 你就是要这个页面里面的内容呗
@哇~怪兽: 我就要这个url 因为是做爬虫的,因为抓取不到,所以我要生成单品页,之后用txt跑单品抓取
@张少: 那你这是要一个程序啊,我去 。半个QQ会员,给你写了 呵呵
@哇~怪兽: O(∩_∩)O哈哈~行啊,等发钱了,我冲的时候给你来一个月的 不是个事
需求确实描述的不是很清晰明确
用Excel不就行了?
些出1个.其他的拖就行了.
不行啊!你只有一个url啊 怎么排序, excel 又不能增加的
一个俩个手动还行 ,我要10000000呢 不就惨了
<html> <head> <script> function CreateFile() { var url = document.getElementById("url").value; var from = parseInt(document.getElementById("from").value); var to = parseInt(document.getElementById("To").value); var array = new Array(); for(var i = from; i <= to; i++) { var line = url + "/" + i.toString(); array.push(line); } WriteToFile(array); } function WriteToFile(array) { var fso, tf; fso = new ActiveXObject("Scripting.FileSystemObject"); tf = fso.CreateTextFile("c:\\test.txt", true); for(var j= 0; j < array.length; j++) { tf.WriteLine(array[j]); } tf.Close(); } </script> </head> <body> URL:<input id = "url" type='text'> </br> From:<input id="from" type = 'text'> </br> To:<input id="To" type = 'text'> </br> <button onclick = "CreateFile();">click me</button> </body> <html>
我不熟悉js,用了我20分钟时间呢,速速给分来。。对了,我没有做数据类型的判断,你再改改。