user116873 user116873 - 7 months ago 31
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?


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.