Solved

stipping out proxy list from web using php

Posted on 2006-11-05
9
42,751 Views
Last Modified: 2011-08-18
Hi,

i would like to know how to code in php to strip proxy list only from a textarea

ex.

in textarea contain

80.249.72.180:80          elite proxy          Algeria (Algiers)
80.249.76.82:80          anonymous          Algeria
190.49.168.251:6588          elite proxy          Argentina (Buenos Aires)
83.160.170.10      8080      transparent      Netherlands      2006-10-25      Whois
203.106.52.102      3128      transparent      Malaysia      2006-10-25      Whois
213.52.140.53      80      anonymous      Great Britain (UK)      2006-10-25      Whois
128.134.137.23:8080 3 Kb/s
138.89.253.5:33322 26 Kb/s
192.38.109.143:3128 23 Kb/s
165.228.131.10      3128      transparent      Australia      2006-10-25      Whois
212.174.34.186      8080      anonymous      Turkey      2006-10-25      Whois
1       202.147.181.2       8080       transparent       Pakistan       2006-11-05       WHOIS
2       62.101.80.187       8080       high anonymity       Italy       2006-11-05       WHOIS
3       84.20.143.8       8080       transparent       Finland       2006-11-05       WHOIS
4       203.115.1.135       80       transparent       Sri Lanka       2006-11-05       WHOIS

here the question:

I want to grab(filter) only

proxy:port

nothing else except that

Thanks
0
Comment
Question by:abangbatax
  • 5
  • 4
9 Comments
 
LVL 29

Accepted Solution

by:
TeRReF earned 125 total points
ID: 17879668
<?php

$s = '80.249.72.180:80          elite proxy          Algeria (Algiers)
80.249.76.82:80          anonymous          Algeria
190.49.168.251:6588          elite proxy          Argentina (Buenos Aires)
83.160.170.10      8080      transparent      Netherlands      2006-10-25      Whois
203.106.52.102      3128      transparent      Malaysia      2006-10-25      Whois
213.52.140.53      80      anonymous      Great Britain (UK)      2006-10-25      Whois
128.134.137.23:8080 3 Kb/s
138.89.253.5:33322 26 Kb/s
192.38.109.143:3128 23 Kb/s
165.228.131.10      3128      transparent      Australia      2006-10-25      Whois
212.174.34.186      8080      anonymous      Turkey      2006-10-25      Whois
1      202.147.181.2      8080      transparent      Pakistan      2006-11-05      WHOIS
2      62.101.80.187      8080      high anonymity      Italy      2006-11-05      WHOIS
3      84.20.143.8      8080      transparent      Finland      2006-11-05      WHOIS
4      203.115.1.135      80      transparent      Sri Lanka      2006-11-05      WHOIS';

preg_match_all('/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})[:\s]*(\d{1,4})/', $s, $matches);
$count = count($matches[1]);
for ($i = 0; $i < $count; $i++)
        $lines[] = $matches[1][$i].':'.$matches[2][$i];

print_r($lines);

?>
0
 

Author Comment

by:abangbatax
ID: 17879944
Hi,

Your answer almost correct for port length 4 ( xxxx) but its not working for
140.134.194.148      49400       TAIWAN (TW)      11/06/2006      Whois Info
it only filter the port to 4940

can you fix it?
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17879980
Try changing this line:
preg_match_all('/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})[:\s]*(\d{1,4})/', $s, $matches);
into
preg_match_all('/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})[:\s]*(\d{1,5})/', $s, $matches);
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:abangbatax
ID: 17880029
Ok, its working...
how about filtering
yoho.uwaterloo.ca:8000   transparent      Pakistan      2006-11-05      WHOIS
kleinbonum.ethz.ch:8000   elite proxy          Algeria (Algiers)
thanks... this will be the last question
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17880082
That's a new question since it requires quite an adjustment to the original regular expression. Why didn't you include these in your original question?
0
 

Author Comment

by:abangbatax
ID: 17880149
ok never minnd...
thanks alot... anyway
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17880458
This should work:

<?php

$s = '80.249.72.180:80          elite proxy          Algeria (Algiers)
80.249.76.82:80          anonymous          Algeria
190.49.168.251:6588          elite proxy          Argentina (Buenos Aires)
83.160.170.10      8080      transparent      Netherlands      2006-10-25      Whois
203.106.52.102      3128      transparent      Malaysia      2006-10-25      Whois
213.52.140.53      80      anonymous      Great Britain (UK)      2006-10-25      Whois
128.134.137.23:8080 3 Kb/s
138.89.253.5:33322 26 Kb/s
192.38.109.143:3128 23 Kb/s
165.228.131.10      3128      transparent      Australia      2006-10-25      Whois
212.174.34.186      8080      anonymous      Turkey      2006-10-25      Whois
1      202.147.181.2      8080      transparent      Pakistan      2006-11-05      WHOIS
2      62.101.80.187      8080      high anonymity      Italy      2006-11-05      WHOIS
3      84.20.143.8      8080      transparent      Finland      2006-11-05      WHOIS
4      203.115.1.135      80      transparent      Sri Lanka      2006-11-05      WHOIS
yoho.uwaterloo.ca:8000   transparent      Pakistan      2006-11-05      WHOIS
kleinbonum.ethz.ch:8000   elite proxy          Algeria (Algiers)';

preg_match_all('/([\w\d]+\.[\w\d\.]+)[:\s]+(\d{1,5})/i', $s, $matches);
$count = count($matches[1]);
for ($i = 0; $i < $count; $i++)
        $lines[] = $matches[1][$i].':'.$matches[2][$i];

print_r($lines);

?>
0
 

Author Comment

by:abangbatax
ID: 17880478
Thanks for all your help!
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17880624
You're welcome :)
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
designing in object programming 12 75
Checking CSRF token within a function 36 74
Presenting past 6 months bug 7 25
Google Maps API and PHP 25 27
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now