PDA

View Full Version : Proxy Lister



A G E N T
12-24-2007, 12:47 AM
This is a script I wrote up, hopefully to be later used with some sort of Google AdSense-abusing mischief ;)

It retrieves a list of proxies from my favourite proxy site, samair.ru; please note that this script was designed with that site and that one only in mind, and will *not* work 'out of the box' with any proxy list site.

The logic is pretty simple, it trims off the heading chunk of useless text, then substr's and regex's the rest of the junk off, then it puts all the proxies into a nice neat array and prints them in the debug for you :spot:

Oh, and BTW, this was written in 3.13, so I'm not sure if it is backwards-compatible.

Enjoy!

program New;
var
Page, Info : string;
Proxies : TStringArray;

function ProxyArray(Delimiter : string; Str : string) : array of string;
var
DelimPos, i : integer;
Arr1 : array of string;
Potential : string;
begin
SetArrayLength(Arr1, 500);
i := 0;
repeat
if (pos(Delimiter, Str) = 0) then Break;
DelimPos := pos(Delimiter, Str);
Potential := Replace((copy(Str,0,DelimPos)),Delimiter,'');
if pos(FindRegex(Potential,'[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'),Potential) <> 0 then
begin
Delete(Potential, (pos(':',Potential)+1),1);
Arr1[i] := Potential;
i := i + 1;
end;
Delete(Str,1,DelimPos);
until(pos(Delimiter, Str) = 0);
SetArrayLength(Arr1, i);
Result := Arr1;
end;

procedure PrintArray(r : TStringArray);
var
i : integer;
begin
i := 0;
repeat
Writeln('Array['+IntToStr(i)+'] = '+r[i]);
i := i + 1;
until(i = GetArrayLength(r));
end;

procedure TrimShit;
var
i : integer;
begin
i := pos('Country',Page);
Delete(Page,1,i);
Delete(Page,1,6);
end;

procedure TrimHTML;
var
StartEncaps, EndEncaps, Length : integer;
begin
repeat
StartEncaps := pos('<',page);
EndEncaps := pos('>',page);
Length := (EndEncaps - StartEncaps) + 1;
Delete(Page,StartEncaps,Length);
until(StartEncaps = 0);
Delete(Page,1,6);
end;

procedure TrimRemnants;
var
StartEncaps, EndEncaps, Length : integer;
begin
repeat
StartEncaps := pos('-',page);
EndEncaps := pos(',',page);
Length := (EndEncaps - StartEncaps) + 1;
Delete(Page,StartEncaps,Length);
until(StartEncaps = 0);
end;

procedure TrimTimes;
begin
Info := ReplaceRegex(Info,'[0-9][0-9]:[0-9][0-9]','');
end;

procedure Clean;
begin
TrimShit;
TrimHTML;
TrimRemnants;
Info := TrimLetters(Page);
TrimTimes;
end;

procedure LoadPage;
begin
Page := GetPage('http://www.samair.ru/proxy');
Clean;
end;

begin
LoadPage;
Proxies := ProxyArray(' ',Info);
PrintArray(Proxies);
end.



EDIT: Some weird stuff going on, it doesn't work 2 hours later. If it doesn't for you, try this one:

program New;
var
Page, Info : string;
Proxies : TStringArray;

function ProxyArray(Delimiter : string; Str : string) : array of string;
var
DelimPos, i : integer;
Arr1 : array of string;
Potential : string;
begin
SetArrayLength(Arr1, 500);
i := 0;
repeat
if (pos(Delimiter, Str) = 0) then Break;
DelimPos := pos(Delimiter, Str);
Potential := Replace((copy(Str,0,DelimPos)),Delimiter,'');
if pos(FindRegex(Potential,'[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'),Potential) <> 0 then
begin
Delete(Potential, (pos(':',Potential)+1),1);
Potential := replace(Potential,'-','');
Arr1[i] := Potential;
i := i + 1;
end;
Delete(Str,1,DelimPos);
until(pos(Delimiter, Str) = 0);
SetArrayLength(Arr1, i);
Result := Arr1;
end;

procedure PrintArray(r : TStringArray);
var
i : integer;
begin
i := 0;
repeat
Writeln('Array['+IntToStr(i)+'] = '+r[i]);
i := i + 1;
until(i = GetArrayLength(r));
end;

procedure TrimShit;
var
i : integer;
begin
i := pos('Country',Page);
Delete(Page,1,i);
Delete(Page,1,6);
end;

procedure TrimHTML;
var
StartEncaps, EndEncaps, Length : integer;
begin
repeat
StartEncaps := pos('<',page);
EndEncaps := pos('>',page);
Length := (EndEncaps - StartEncaps) + 1;
Delete(Page,StartEncaps,Length);
until(StartEncaps = 0);
Delete(Page,1,6);
end;

procedure TrimRemnants;
var
StartEncaps, EndEncaps, Length : integer;
begin
repeat
StartEncaps := pos('-',Info);
EndEncaps := pos(',',Info);
Length := (EndEncaps - StartEncaps) + 1;
Delete(Info, StartEncaps, Length);
until(StartEncaps = 0);
end;

procedure TrimTimes;
begin
Info := ReplaceRegex(Info,'[0-9][0-9]:[0-9][0-9]','');
end;

procedure Clean;
begin
TrimShit;
TrimHTML;
TrimRemnants;
Info := TrimLetters(Page);
TrimTimes;
end;

procedure LoadPage;
begin
Page := GetPage('http://www.samair.ru/proxy');
Clean;
end;

begin
LoadPage;
Proxies := ProxyArray(' ', Info);
PrintArray(Proxies);
end.

Sp0rky
12-24-2007, 01:03 AM
Wow, great job, looks very sexy and original. First post, Grats =P

[S]paz
12-24-2007, 01:18 AM
nice work, but couldnt u just go to the website and find them manually?? :P

lol but its nice

~Spaz

A G E N T
12-24-2007, 02:38 AM
But this way you can cycle through a lot of proxies, then rape AdSense overnight :P

TViYH
12-24-2007, 04:09 AM
Proxies never work for me on firefox...It takes 10x longer to load the sites...I just use http://www.kproxy.com/

Daniel
12-24-2007, 06:09 AM
Could you make it work with http://proxy.org? As that is a very good source list for proxies.

Plus, i do not understand this code ><

A G E N T
12-24-2007, 05:08 PM
Could you make it work with http://proxy.org? As that is a very good source list for proxies.

Plus, i do not understand this code ><

Proxy.org provides just web proxies, right? If that's the case, it ought to be a pretty simple matter of mouse-clicking your way around.

I can comment the script if you want :)

Negaal
12-25-2007, 12:17 AM
Agent, you should apply to SRL memebrs if you made it yourslef, but you need a runescaoe script...


Hmmm...mhhh I have to admit I can't understand not a single thing there

A G E N T
12-28-2007, 01:17 AM
Thanks :) I just need a good idea for a script.

A runthrough of the logic for anyone who is confused:

1) TrimShit --> Site-specific, it trims off useless text starting at the beginning of the page and ending at the last word before the list starts. ("Country").

2) TrimHTML --> Deletes any HTML tags, (<>) and anything encapsulated in them; works by repeatedly searching with pos() and deleting with delete(). The delete(Page,1,6) at the end is also site-specific; it trims off whitespace and a table character at the beginning.

3)TrimRemnants --> Rather specific, gets rid of some date text.

4)TrimTimes --> Uses a 'regex' or regular expression to find any dates, regexes are a bit tricky but this particular one ("[0-9][0-9]:[0-9][0-9]") finds any 2 digits (from 1 to 9) followed by a colon, then another 2 digits. Essentially, it deletes the 24h clock time stamps.

5) ProxyArray --> The real heart of the script...
By this point, all that's left of the page is the proxies with spaces and sometimes whitespace in between them, and a table character between the colon and the port number.

This sets up a big, empty array, then starts a loop. It then finds the first instance of the delimiter, the space between the proxies, then uses this position as reference to pick out just one proxy, by using Potential :=Replace((copy(Str,0,DelimPos)),Delimiter,'');

This creates a new string called "Potential" by copying the text up to the delimiter, then deleting said delimiter. Next, it uses this:

if pos(FindRegex(Potential,'[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'),Potential) <> 0 then
begin
Delete(Potential, (pos(':',Potential)+1),1);
Potential := replace(Potential,'-','');
Arr1[i] := Potential;
i := i + 1;
end;
Delete(Str,1,DelimPos);


The first line uses pos() to search, using another regex to check whether the string we have selected is in proxy format (number.number.number.number). Next, it deletes the table character between the colon and the port. Lastly, it strips any hyphens from the proxy, adds it to the array, then deletes it from the string to avoid repeats.

Hope I was clear enough, enjoy!