01.
using
System.Collections.Generic;
02.
using
System.ComponentModel;
03.
using
System.Data;
04.
using
System.Drawing;
05.
using
System.Linq;
06.
using
System.Text;
07.
using
System.Windows.Forms;
08.
using
System;
09.
10.
namespace
LoadOne2UpIDM
11.
{
12.
public
partial
class
Form2 : Form
13.
{
14.
public
Form2()
15.
{
16.
InitializeComponent();
17.
}
18.
19.
20.
System.Text.RegularExpressions.Regex regexListcontent_ID =
new
System.Text.RegularExpressions.Regex(@
"(?:<div.*?(view_content.php\?content_ID=[0-9]+)\""
.*?<b>(.*?)<.*?ขนาดไฟล์(.*?)<br>)", System.Text.RegularExpressions.RegexOptions.Singleline | System.Text.RegularExpressions.RegexOptions.CultureInvariant);
21.
System.Text.RegularExpressions.Regex regexLinkFile =
new
System.Text.RegularExpressions.Regex(
"(?:\"txt_URL\" id=\"txt_URL\" value)=[\"|']?(.*?)[\"|'|>]"
, System.Text.RegularExpressions.RegexOptions.Singleline | System.Text.RegularExpressions.RegexOptions.CultureInvariant);
22.
System.Text.RegularExpressions.Regex regexFileName =
new
System.Text.RegularExpressions.Regex(
"(?:content=\"Other->)(.*?)[\"|'|>|/]+"
, System.Text.RegularExpressions.RegexOptions.Singleline | System.Text.RegularExpressions.RegexOptions.CultureInvariant);
23.
string
pathIDM = @
"C:\Program Files\Internet Download Manager\IDMan.exe"
;
24.
string
getHTML(
string
url)
25.
{
26.
string
html =
""
;
27.
try
28.
{
29.
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url.Trim());
30.
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
31.
System.IO.StreamReader sr =
new
System.IO.StreamReader(response.GetResponseStream());
32.
html = sr.ReadToEnd();
33.
sr.Close();
34.
response.Close();
35.
}
36.
catch
{ }
37.
return
html;
38.
}
39.
void
getListHTML(
string
strsearch,
int
_min,
int
_max)
40.
{
41.
for
(
int
i = _min; i <= _max; i++)
42.
{
43.
45.
System.Threading.Thread.Sleep(100);
46.
}
47.
}
48.
void
getListHTML(
string
URL)
49.
{
50.
getListHTML(
new
object
[] { URL });
51.
}
52.
void
getListHTML(
object
obj)
53.
{
54.
string
url = (
string
)((
object
[])obj)[0];
55.
this
.Invoke(
new
Action(() => {
this
.Text = url; }));
56.
foreach
(System.Text.RegularExpressions.Match match
in
regexListcontent_ID.Matches(getHTML(url)))
57.
{
58.
dataGridView1.Invoke(
new
Action(() => { dataGridView1.Rows.Add(
true
,
"http://www.one2up.com/"
+ match.Groups[1].Value, match.Groups[2].Value, match.Groups[3].Value, GetLinkByID(
"http://www.one2up.com/"
+ match.Groups[1].Value)); }));
59.
System.Threading.Thread.Sleep(100);
60.
}
61.
62.
}
63.
string
GetLinkByID(
string
URL_ID)
64.
{
65.
return
(URL_ID ==
null
|| URL_ID ==
string
.Empty) ?
""
: regexLinkFile.Matches(getHTML(URL_ID))[0].Groups[1].Value;
66.
}
67.
void
LoadOne2UpByID()
68.
{
69.
for
(
int
i = 0; i < dataGridView1.RowCount - 1; i++)
70.
{
71.
if
((
bool
)dataGridView1[0, i].Value ==
true
&& dataGridView1[2, i].Value.ToString() !=
"xxx"
)
72.
{
73.
System.Diagnostics.Process.Start(pathIDM,
"/a /n /d "
+ dataGridView1[4, i].Value.ToString() +
" /f \""
+ dataGridView1[2, i].Value.ToString() +
"\""
);
74.
System.Threading.Thread.Sleep(200);
75.
}
76.
}
77.
}
78.
private
void
button1_Click(
object
sender, EventArgs e)
79.
{
80.
81.
getListHTML(textBox1.Text);
82.
83.
}
84.
private
void
button2_Click(
object
sender, EventArgs e)
85.
{
86.
87.
88.
}
89.
90.
private
void
button3_Click(
object
sender, EventArgs e)
91.
{
92.
93.
new
System.Threading.Thread(LoadOne2UpByID).Start();
94.
}
95.
}
96.
}