Here is what I'm trying to accomplish:
- Using python mechanize I open a site
- If content does not match my regex I open another site
- I perform searching using another regex
And the extracted code:
m = re.search('<td>(?P<alt>\d+)', response.read())
...
m = re.search('<td>(?P<alt>\w+)', response.read())
print m.group('alt')
I'm getting:
AttributeError: 'NoneType' object has no attribute 'group'
If I uncomment the second search everything is fine. I don't understand this behaviour.
Such an error redirected me to this stackoverflow issue and to this - but to no avail - neither of these solved my problem.
I don't care about efficiency here so I don't use compile
.