user116873 user116873 - 1 year ago 79
Python Question

Python: loop through different url in list

I have some url

I need to open content of page that url:

I try to write regular expression:

if 'drom\.ru/.?*/.?*/\d\.html' in url:
print url

But it returns nothing strings.
What I do wrong?

Answer Source

Please check the below code.

  • It seems the url you want to search has SomeNumber.html format. Written regex for the same.

url_list = [

import re

for url in url_list:
    m ='.*\/\d+\.html',url)
    if m is not None:
        print url




Please check this link for regex verification in python.

Also, please check more info regarding re module here !!!

Thanks to shutdown-hnow for pointing toward this.

You can check this link for debugging regex.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download