0

So I have a RegEx stament to download files from a website im scraping(personal prject of mine) and I would like to download the files found by the regex statements

Question: How could i do this using urllib or urllib2?

def GetImage():
    with open('TestPage.txt') as f:
        for line in f:
            v = re.findall(r'\w+\.jpg|\w+\.bmp|\w+.\gif', line)
            if v:
                os.system("wget v") # Could I replace this with urllib.retrieve(v)?
                #Code to download files found in v should go here.
                print v

def main():
    url = "http://testpage/~drc/drx/index.html"
    webpage = urllib2.urlopen(url)

    content = webpage.read()
    f = open('TestPage.txt', 'w')
    f.write(content)
    f.close()

I know that I can download one file from a specific URL, but downloading the images found in regex v is my problem

K DawG
  • 13,287
  • 9
  • 35
  • 66
Scott
  • 43
  • 3

0 Answers0