samwize / python-email-crawler

Search on Google, and crawls for emails related to the result
292 stars 127 forks source link

except urllib2.URLError, e: #19

Open Heyii opened 6 years ago

Heyii commented 6 years ago
HaoyuedeMacBook:python-email-crawler haoyue$ python email_crawler.py "iphone developers"
  File "email_crawler.py", line 96
    except urllib2.URLError, e:
                           ^
SyntaxError: invalid syntax

I run this code two weeks ago, it works well, but it threw a syntaxError today when I tried to run it again. What does this mean? Sorry, I am using this crawler for a research, thank you for your code.

MaximRudenko commented 5 years ago

I had the same issue, then fixed it by changing python interpreter from 3 to 2: "py -2 email_crawler.py ...", but then I've got an error #22 To be honest, I don't know how to fix it, but running script from pythonanywhere.com solves everything. UPDATE: Another solution for this issue might be Anaconda for Python 2.7

MarcoCiaramella commented 5 years ago

replace except urllib2.URLError, e: with except urllib2.URLError as e:

and try again

concamuflage commented 4 years ago

I had the same problem because I runned email_crawler.py within the conda environment, which has a 3.7 python interpretor. There is no urllib2 package for python 3 so we must install a python 2.7 interpreter. As bonus, urllib2 is already included in python 2.7.

I solved this issue by running the downloaded program in a virtual environment.

First step, we must create a virtual environment which contains the python 2.7 and the required package.

Second step, open the downloaded program/script folder in VS code.

Third step, activate the virtual environment in the vs code terminal Last step, type in your terminal python email_crawler.py "your key word"

I found this program not very useful as I saw it kept crawling pages what cannot possiblely contain an email address. I kept crawling the same site for almost 10 minutes! I think the algorithm/logic need to be improved.