-1

Hi i want to grab ip and port on https://www.socks-proxy.net/. I can grab ip with regex pattern

'/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/'

but how to grab port ? i only can grab ip without port. How i can grab ip and port?

Murat Karagöz
  • 35,401
  • 16
  • 78
  • 107
Janu Yoga
  • 1
  • 5

1 Answers1

0

Just have a look an the source code of the website. You can see, that everything is separated by TD-Tags.

So you would have to expand your regex to get the next column like this: (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})<\/td><td>(\d{1,5})

See results here: https://regex101.com/r/V7sh0d/1

Michael Walter
  • 1,427
  • 12
  • 28
  • i saw timeout on https://regex101.com/r/V7sh0d/1 – Janu Yoga Jul 31 '17 at 12:49
  • It's working an my machine. Just try the regex in your project. It should work there as well. – Michael Walter Jul 31 '17 at 12:51
  • thanks sir you save my time, i use preg_match_all('/<\/td>(\d{1,5})/', $str, $match); – Janu Yoga Jul 31 '17 at 13:09
  • This could also match for the column `last checked` (because `\d{1,5}` will match for '33 seconds ago'. I would recommend to use my version. You can just group the 2nd part, but you should use the whole statement. Please accept my answer as a solution when you are happy with the outcome – Michael Walter Jul 31 '17 at 22:43