How to use regular expressions to extract ip ports from a web page?

problem description

about regular expressions
problems with extracting ip and port from a proxy website found while acting as a proxy pool

related codes

/ / Please paste the code text below
< tr >
< td > 1 < / td >
< td > 115.159.100.19 < / td >
< td > 8998 < / td >
< td > Shanghai td >
< td > Shanghai < / td >
< td > high < / td >
< td > 7.05ms < / td >

< td >
7 minutes ago

< / td >
< td > copy < / td >
< / tr >
< tr >
< td > 2 < / td >
< td > 221.229.166.55 < / td >
< td > 8080 < / td >
< td > Jiangsu < / td >
< td > Xuzhou A > < / td >
< td > 21.26ms < / td >

< td >
7 minutes ago

I wrote the regular expression re.findall ("< td >. ? < td > (. ). *? (d +) < / td >, html,re.S)
I don"t know why I can"t get the results all the time. I hope the bosses can give us some advice

.

what result do you expect?


use regular ((\ d +\.) {3}\ d +) [^\ d] +? < td > (\ d +) match to each match where group1 is ip,group3 and port

Menu