PDA

View Full Version : [SOLVED] Wildcards in python?



HalfEmptyHero
January 30th, 2010, 07:52 AM
I want to scan an html file, looking for images, and add the url of the image to a list, however I am not sure how to do this. Is there any way to do wildcards in python, such as:

if 'http://www.'*'.jpg' in file:
list.append(item)

or something that works to that degree. Or some other way to do this.

nvteighen
January 30th, 2010, 12:04 PM
You need a regular expression. Look at the re module.

ricegf
January 30th, 2010, 01:30 PM
You might also want to check into Beautiful Soup (http://www.crummy.com/software/BeautifulSoup/), a Python library useful for efficiently and usefully dissecting web pages. It's particularly adept at handling badly-coded pages such as you often find on the open web.

HalfEmptyHero
January 30th, 2010, 04:47 PM
Excellent thanks for the help.