Reputation: 177
I'm trying to take information from a site, read it in line by line and only take the lines that start with two digits, a semicolon, two digits a semicolon and two more digits (i.e. 00:00:00). Matches are exported to another file.
I am getting a syntax error for the semicolons in my regex.
#!/usr/bin/python
import urllib2
import re
#imported urllib to collect the data. imported re for regular expressions to test format.
#creating our output file
f=open("output.txt", "r+")
#opening a file like object using urllib
webpage= urllib2.open("https://code.wireshark.org/review/gitweb?p=wireshark.git;a=blob_plain;f=manuf")
#string used to store the output
str=""
#string used to store current line
temp=""
#add while loop to read in that data. line by line.
temp=webpage.readline()
if temp.re.search([0-9][0-9]:[0-9][0-9]:[0-9][0-9]):
str.concat(temp)
temp=""
Upvotes: 0
Views: 69
Reputation: 1398
You are searching using raw code, try inputting a string
if temp.re.search("[0-9][0-9]:[0-9][0-9]:[0-9][0-9]"):
Upvotes: 2