I have a simple script below that is causing me some problems and I am
having a hard time tracking them down. Here is the code:
import urllib
import re
def getPicLinks():
found = []
try:
page =
urllib.urlopen( "http://continuouswave. com/whaler/cetacea/")
except:
print "ERROR RREADING PAGE."
sys.exit()
page1 = page.read()
cetLinks = re.compile("cet aceaPage..\.htm l", page1)
for line in page1:
found.append(ce tLinks.findall( line))
print found
This is the error message:
"/Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/sre_parse.py",
line 396, in _parse
if state.flags & SRE_FLAG_VERBOS E:
TypeError: unsupported operand type(s) for &: 'str' and 'int'
I am trying to extract the links on a web page that have a similar
pattern. Here is an example of the html source:
<HR>
<P><SMALL><A HREF="photoLog. html">PHOTO-LOG</A><br>
<A HREF="guide.htm l">How-To-Submit</A><BR><A
HREF="cetaceaPa ge01.html">01</A> | <A
HREF="cetaceaPa ge02.html">02</A> | <A
HREF="cetaceaPa ge03.html">03</A> | <A
HREF="cetaceaPa ge04.html">04</A> | <A
HREF="cetaceaPa ge05.html">05</A> | <A
HREF="cetaceaPa ge06.html">06</A> | <A
HREF="cetaceaPa ge07.html">07</A> | <A
HREF="cetaceaPa ge08.html">08</A> | <A
HREF="cetaceaPa ge09.html">09</A> | <A
HREF="cetaceaPa ge10.html">10</A>
<BR><A>
My problem is that I can't seem to be able to figure out what is going
wrong here. Mostly because I am a bit confused by the error message as
it points to a file (presumable part of re) that I am unfamiliar with,
and I am a bit new with python.
Any help is greatly appreciated, as is your patience.
Brian
having a hard time tracking them down. Here is the code:
import urllib
import re
def getPicLinks():
found = []
try:
page =
urllib.urlopen( "http://continuouswave. com/whaler/cetacea/")
except:
print "ERROR RREADING PAGE."
sys.exit()
page1 = page.read()
cetLinks = re.compile("cet aceaPage..\.htm l", page1)
for line in page1:
found.append(ce tLinks.findall( line))
print found
This is the error message:
"/Library/Frameworks/Python.framewor k/Versions/2.4/lib/python2.4/sre_parse.py",
line 396, in _parse
if state.flags & SRE_FLAG_VERBOS E:
TypeError: unsupported operand type(s) for &: 'str' and 'int'
I am trying to extract the links on a web page that have a similar
pattern. Here is an example of the html source:
<HR>
<P><SMALL><A HREF="photoLog. html">PHOTO-LOG</A><br>
<A HREF="guide.htm l">How-To-Submit</A><BR><A
HREF="cetaceaPa ge01.html">01</A> | <A
HREF="cetaceaPa ge02.html">02</A> | <A
HREF="cetaceaPa ge03.html">03</A> | <A
HREF="cetaceaPa ge04.html">04</A> | <A
HREF="cetaceaPa ge05.html">05</A> | <A
HREF="cetaceaPa ge06.html">06</A> | <A
HREF="cetaceaPa ge07.html">07</A> | <A
HREF="cetaceaPa ge08.html">08</A> | <A
HREF="cetaceaPa ge09.html">09</A> | <A
HREF="cetaceaPa ge10.html">10</A>
<BR><A>
My problem is that I can't seem to be able to figure out what is going
wrong here. Mostly because I am a bit confused by the error message as
it points to a file (presumable part of re) that I am unfamiliar with,
and I am a bit new with python.
Any help is greatly appreciated, as is your patience.
Brian
Comment