Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import csv
- from urllib import urlopen
- import re
- # Open and read HTMl / XML
- xml = urlopen("htmlb.html").read()
- # Grab article titles and links using regex
- xmlTitle = re.compile("'detlink'(.*)>")
- # Find and store the data
- findTitle = re.findall(xmlTitle,xml)
- #Iterate through the articles to create a range
- iterate = []
- iterate[:] = range(1, 200)
- # Open the CSV file, write the headers
- writer = csv.writer(open("pytest.csv", "wb"))
- # Using a For Loop, write the results to the CSV file, row by row
- for i in iterate:
- writer.writerow([findTitle[i]])
- The error given:
- list index out of range error
- Error given when:
- xmlTitle = re.compile("'detlink'(.*)>")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement